mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-08 03:01:43 +09:00
issue 2119. supporting php 5.4. editor, extravar and file classes.
git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12688 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
1de3e9cd17
commit
b69abcca68
5 changed files with 700 additions and 356 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Superclass of the edit component.
|
* Superclass of the edit component.
|
||||||
* Set up the component variables
|
* Set up the component variables
|
||||||
|
|
@ -8,16 +9,20 @@
|
||||||
*/
|
*/
|
||||||
class EditorHandler extends Object
|
class EditorHandler extends Object
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set the xml and other information of the component
|
* set the xml and other information of the component
|
||||||
* @param object $info editor information
|
* @param object $info editor information
|
||||||
* @return void
|
* @return void
|
||||||
**/
|
* */
|
||||||
function setInfo($info)
|
function setInfo($info)
|
||||||
{
|
{
|
||||||
Context::set('component_info', $info);
|
Context::set('component_info', $info);
|
||||||
|
|
||||||
if(!$info->extra_vars) return;
|
if(!$info->extra_vars)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach($info->extra_vars as $key => $val)
|
foreach($info->extra_vars as $key => $val)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class to handle extra variables used in posts, member and others
|
* A class to handle extra variables used in posts, member and others
|
||||||
*
|
*
|
||||||
|
|
@ -6,6 +7,7 @@
|
||||||
*/
|
*/
|
||||||
class ExtraVar
|
class ExtraVar
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sequence of module
|
* sequence of module
|
||||||
* @var int
|
* @var int
|
||||||
|
|
@ -48,7 +50,11 @@ class ExtraVar
|
||||||
*/
|
*/
|
||||||
function setExtraVarKeys($extra_keys)
|
function setExtraVarKeys($extra_keys)
|
||||||
{
|
{
|
||||||
if(!is_array($extra_keys) || !count($extra_keys)) return;
|
if(!is_array($extra_keys) || !count($extra_keys))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach($extra_keys as $key => $val)
|
foreach($extra_keys as $key => $val)
|
||||||
{
|
{
|
||||||
$obj = null;
|
$obj = null;
|
||||||
|
|
@ -66,6 +72,7 @@ class ExtraVar
|
||||||
{
|
{
|
||||||
return $this->keys;
|
return $this->keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -75,6 +82,7 @@ class ExtraVar
|
||||||
*/
|
*/
|
||||||
class ExtraItem
|
class ExtraItem
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sequence of module
|
* Sequence of module
|
||||||
* @var int
|
* @var int
|
||||||
|
|
@ -151,7 +159,11 @@ class ExtraItem
|
||||||
*/
|
*/
|
||||||
function ExtraItem($module_srl, $idx, $name, $type = 'text', $default = null, $desc = '', $is_required = 'N', $search = 'N', $value = null, $eid = '')
|
function ExtraItem($module_srl, $idx, $name, $type = 'text', $default = null, $desc = '', $is_required = 'N', $search = 'N', $value = null, $eid = '')
|
||||||
{
|
{
|
||||||
if(!$idx) return;
|
if(!$idx)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->module_srl = $module_srl;
|
$this->module_srl = $module_srl;
|
||||||
$this->idx = $idx;
|
$this->idx = $idx;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
|
|
@ -185,47 +197,92 @@ class ExtraItem
|
||||||
function _getTypeValue($type, $value)
|
function _getTypeValue($type, $value)
|
||||||
{
|
{
|
||||||
$value = trim($value);
|
$value = trim($value);
|
||||||
if(!isset($value)) return;
|
if(!isset($value))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch($type)
|
switch($type)
|
||||||
{
|
{
|
||||||
case 'homepage' :
|
case 'homepage' :
|
||||||
if($value && !preg_match('/^([a-z]+):\/\//i',$value)) $value = 'http://'.$value;
|
if($value && !preg_match('/^([a-z]+):\/\//i', $value))
|
||||||
|
{
|
||||||
|
$value = 'http://' . $value;
|
||||||
|
}
|
||||||
return htmlspecialchars($value);
|
return htmlspecialchars($value);
|
||||||
break;
|
|
||||||
case 'tel' :
|
case 'tel' :
|
||||||
if(is_array($value)) $values = $value;
|
if(is_array($value))
|
||||||
elseif(strpos($value,'|@|')!==false) $values = explode('|@|', $value);
|
{
|
||||||
elseif(strpos($value,',')!==false) $values = explode(',', $value);
|
$values = $value;
|
||||||
|
}
|
||||||
|
elseif(strpos($value, '|@|') !== FALSE)
|
||||||
|
{
|
||||||
|
$values = explode('|@|', $value);
|
||||||
|
}
|
||||||
|
elseif(strpos($value, ',') !== FALSE)
|
||||||
|
{
|
||||||
|
$values = explode(',', $value);
|
||||||
|
}
|
||||||
|
|
||||||
$values[0] = $values[0];
|
$values[0] = $values[0];
|
||||||
$values[1] = $values[1];
|
$values[1] = $values[1];
|
||||||
$values[2] = $values[2];
|
$values[2] = $values[2];
|
||||||
return $values;
|
return $values;
|
||||||
break;
|
|
||||||
break;
|
|
||||||
case 'checkbox' :
|
case 'checkbox' :
|
||||||
case 'radio' :
|
case 'radio' :
|
||||||
case 'select' :
|
case 'select' :
|
||||||
if(is_array($value)) $values = $value;
|
if(is_array($value))
|
||||||
elseif(strpos($value,'|@|')!==false) $values = explode('|@|', $value);
|
{
|
||||||
elseif(strpos($value,',')!==false) $values = explode(',', $value);
|
$values = $value;
|
||||||
else $values = array($value);
|
}
|
||||||
for($i=0;$i<count($values);$i++) $values[$i] = htmlspecialchars($values[$i]);
|
elseif(strpos($value, '|@|') !== FALSE)
|
||||||
|
{
|
||||||
|
$values = explode('|@|', $value);
|
||||||
|
}
|
||||||
|
elseif(strpos($value, ',') !== FALSE)
|
||||||
|
{
|
||||||
|
$values = explode(',', $value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$values = array($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
for($i = 0; $i < count($values); $i++)
|
||||||
|
{
|
||||||
|
$values[$i] = htmlspecialchars($values[$i]);
|
||||||
|
}
|
||||||
|
|
||||||
return $values;
|
return $values;
|
||||||
break;
|
|
||||||
case 'kr_zip' :
|
case 'kr_zip' :
|
||||||
if(is_array($value)) $values = $value;
|
if(is_array($value))
|
||||||
elseif(strpos($value,'|@|')!==false) $values = explode('|@|', $value);
|
{
|
||||||
elseif(strpos($value,',')!==false) $values = explode(',', $value);
|
$values = $value;
|
||||||
else $values = array($value);
|
}
|
||||||
|
elseif(strpos($value, '|@|') !== false)
|
||||||
|
{
|
||||||
|
$values = explode('|@|', $value);
|
||||||
|
}
|
||||||
|
elseif(strpos($value, ',') !== false)
|
||||||
|
{
|
||||||
|
$values = explode(',', $value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$values = array($value);
|
||||||
|
}
|
||||||
|
|
||||||
return $values;
|
return $values;
|
||||||
break;
|
|
||||||
//case 'date' :
|
//case 'date' :
|
||||||
//case 'email_address' :
|
//case 'email_address' :
|
||||||
//case 'text' :
|
//case 'text' :
|
||||||
//case 'textarea' :
|
//case 'textarea' :
|
||||||
default :
|
default :
|
||||||
return htmlspecialchars($value);
|
return htmlspecialchars($value);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -237,35 +294,55 @@ class ExtraItem
|
||||||
function getValueHTML()
|
function getValueHTML()
|
||||||
{
|
{
|
||||||
$value = $this->_getTypeValue($this->type, $this->value);
|
$value = $this->_getTypeValue($this->type, $this->value);
|
||||||
|
|
||||||
switch($this->type)
|
switch($this->type)
|
||||||
{
|
{
|
||||||
case 'homepage' :
|
case 'homepage' :
|
||||||
return ($value)?(sprintf('<a href="%s" target="_blank">%s</a>', $value, strlen($value)>60?substr($value,0,40).'...'.substr($value,-10):$value)):"";
|
return ($value) ? (sprintf('<a href="%s" target="_blank">%s</a>', $value, strlen($value) > 60 ? substr($value, 0, 40) . '...' . substr($value, -10) : $value)) : "";
|
||||||
|
|
||||||
case 'email_address' :
|
case 'email_address' :
|
||||||
return ($value)?sprintf('<a href="mailto:%s">%s</a>', $value, $value):"";
|
return ($value) ? sprintf('<a href="mailto:%s">%s</a>', $value, $value) : "";
|
||||||
break;
|
|
||||||
case 'tel' :
|
case 'tel' :
|
||||||
return sprintf('%s - %s - %s', $value[0],$value[1],$value[2]);
|
return sprintf('%s - %s - %s', $value[0], $value[1], $value[2]);
|
||||||
break;
|
|
||||||
case 'textarea' :
|
case 'textarea' :
|
||||||
return nl2br($value);
|
return nl2br($value);
|
||||||
break;
|
|
||||||
case 'checkbox' :
|
case 'checkbox' :
|
||||||
if(is_array($value)) return implode(', ',$value);
|
if(is_array($value))
|
||||||
else return $value;
|
{
|
||||||
break;
|
return implode(', ', $value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
case 'date' :
|
case 'date' :
|
||||||
return zdate($value,"Y-m-d");
|
return zdate($value, "Y-m-d");
|
||||||
break;
|
|
||||||
case 'select' :
|
case 'select' :
|
||||||
case 'radio' :
|
case 'radio' :
|
||||||
if(is_array($value)) return implode(', ',$value);
|
if(is_array($value))
|
||||||
else return $value;
|
{
|
||||||
break;
|
return implode(', ', $value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
case 'kr_zip' :
|
case 'kr_zip' :
|
||||||
if(is_array($value)) return implode(' ',$value);
|
if(is_array($value))
|
||||||
else return $value;
|
{
|
||||||
break;
|
return implode(' ', $value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
// case 'text' :
|
// case 'text' :
|
||||||
default :
|
default :
|
||||||
return $value;
|
return $value;
|
||||||
|
|
@ -285,54 +362,66 @@ class ExtraItem
|
||||||
$name = $this->name;
|
$name = $this->name;
|
||||||
$value = $this->_getTypeValue($this->type, $this->value);
|
$value = $this->_getTypeValue($this->type, $this->value);
|
||||||
$default = $this->_getTypeValue($this->type, $this->default);
|
$default = $this->_getTypeValue($this->type, $this->default);
|
||||||
$column_name = 'extra_vars'.$this->idx;
|
$column_name = 'extra_vars' . $this->idx;
|
||||||
$tmp_id = $column_name.'-'.$id_num++;
|
$tmp_id = $column_name . '-' . $id_num++;
|
||||||
|
|
||||||
$buff = '';
|
$buff = '';
|
||||||
switch($type)
|
switch($type)
|
||||||
{
|
{
|
||||||
// Homepage
|
// Homepage
|
||||||
case 'homepage' :
|
case 'homepage' :
|
||||||
$buff .= '<input type="text" name="'.$column_name.'" value="'.$value.'" class="homepage" />';
|
$buff .= '<input type="text" name="' . $column_name . '" value="' . $value . '" class="homepage" />';
|
||||||
break;
|
break;
|
||||||
// Email Address
|
// Email Address
|
||||||
case 'email_address' :
|
case 'email_address' :
|
||||||
$buff .= '<input type="text" name="'.$column_name.'" value="'.$value.'" class="email_address" />';
|
$buff .= '<input type="text" name="' . $column_name . '" value="' . $value . '" class="email_address" />';
|
||||||
break;
|
break;
|
||||||
// Phone Number
|
// Phone Number
|
||||||
case 'tel' :
|
case 'tel' :
|
||||||
$buff .=
|
$buff .=
|
||||||
'<input type="text" name="'.$column_name.'[]" value="'.$value[0].'" size="4" maxlength="4" class="tel" />'.
|
'<input type="text" name="' . $column_name . '[]" value="' . $value[0] . '" size="4" maxlength="4" class="tel" />' .
|
||||||
'<input type="text" name="'.$column_name.'[]" value="'.$value[1].'" size="4" maxlength="4" class="tel" />'.
|
'<input type="text" name="' . $column_name . '[]" value="' . $value[1] . '" size="4" maxlength="4" class="tel" />' .
|
||||||
'<input type="text" name="'.$column_name.'[]" value="'.$value[2].'" size="4" maxlength="4" class="tel" />';
|
'<input type="text" name="' . $column_name . '[]" value="' . $value[2] . '" size="4" maxlength="4" class="tel" />';
|
||||||
break;
|
break;
|
||||||
// textarea
|
// textarea
|
||||||
case 'textarea' :
|
case 'textarea' :
|
||||||
$buff .= '<textarea name="'.$column_name.'" rows="8" cols="42">'.$value.'</textarea>';
|
$buff .= '<textarea name="' . $column_name . '" rows="8" cols="42">' . $value . '</textarea>';
|
||||||
break;
|
break;
|
||||||
// multiple choice
|
// multiple choice
|
||||||
case 'checkbox' :
|
case 'checkbox' :
|
||||||
$buff .= '<ul>';
|
$buff .= '<ul>';
|
||||||
foreach($default as $v)
|
foreach($default as $v)
|
||||||
{
|
{
|
||||||
if($value && in_array(trim($v), $value)) $checked = ' checked="checked"';
|
if($value && in_array(trim($v), $value))
|
||||||
else $checked = '';
|
{
|
||||||
|
$checked = ' checked="checked"';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$checked = '';
|
||||||
|
}
|
||||||
|
|
||||||
// Temporary ID for labeling
|
// Temporary ID for labeling
|
||||||
$tmp_id = $column_name.'-'.$id_num++;
|
$tmp_id = $column_name . '-' . $id_num++;
|
||||||
|
|
||||||
$buff .='<li><input type="checkbox" name="'.$column_name.'[]" id="'.$tmp_id.'" value="'.htmlspecialchars($v).'" '.$checked.' /><label for="'.$tmp_id.'">'.$v.'</label></li>';
|
$buff .='<li><input type="checkbox" name="' . $column_name . '[]" id="' . $tmp_id . '" value="' . htmlspecialchars($v) . '" ' . $checked . ' /><label for="' . $tmp_id . '">' . $v . '</label></li>';
|
||||||
}
|
}
|
||||||
$buff .= '</ul>';
|
$buff .= '</ul>';
|
||||||
break;
|
break;
|
||||||
// single choice
|
// single choice
|
||||||
case 'select' :
|
case 'select' :
|
||||||
$buff .= '<select name="'.$column_name.'" class="select">';
|
$buff .= '<select name="' . $column_name . '" class="select">';
|
||||||
foreach($default as $v)
|
foreach($default as $v)
|
||||||
{
|
{
|
||||||
if($value && in_array(trim($v),$value)) $selected = ' selected="selected"';
|
if($value && in_array(trim($v), $value))
|
||||||
else $selected = '';
|
{
|
||||||
$buff .= '<option value="'.$v.'" '.$selected.'>'.$v.'</option>';
|
$selected = ' selected="selected"';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$selected = '';
|
||||||
|
}
|
||||||
|
$buff .= '<option value="' . $v . '" ' . $selected . '>' . $v . '</option>';
|
||||||
}
|
}
|
||||||
$buff .= '</select>';
|
$buff .= '</select>';
|
||||||
break;
|
break;
|
||||||
|
|
@ -341,13 +430,19 @@ class ExtraItem
|
||||||
$buff .= '<ul>';
|
$buff .= '<ul>';
|
||||||
foreach($default as $v)
|
foreach($default as $v)
|
||||||
{
|
{
|
||||||
if($value && in_array(trim($v),$value)) $checked = ' checked="checked"';
|
if($value && in_array(trim($v), $value))
|
||||||
else $checked = '';
|
{
|
||||||
|
$checked = ' checked="checked"';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$checked = '';
|
||||||
|
}
|
||||||
|
|
||||||
// Temporary ID for labeling
|
// Temporary ID for labeling
|
||||||
$tmp_id = $column_name.'-'.$id_num++;
|
$tmp_id = $column_name . '-' . $id_num++;
|
||||||
|
|
||||||
$buff .= '<li><input type="radio" name="'.$column_name.'" id="'.$tmp_id.'" '.$checked.' value="'.$v.'" class="radio" /><label for="'.$tmp_id.'">'.$v.'</label></li>';
|
$buff .= '<li><input type="radio" name="' . $column_name . '" id="' . $tmp_id . '" ' . $checked . ' value="' . $v . '" class="radio" /><label for="' . $tmp_id . '">' . $v . '</label></li>';
|
||||||
}
|
}
|
||||||
$buff .= '</ul>';
|
$buff .= '</ul>';
|
||||||
break;
|
break;
|
||||||
|
|
@ -357,22 +452,22 @@ class ExtraItem
|
||||||
Context::loadJavascriptPlugin('ui.datepicker');
|
Context::loadJavascriptPlugin('ui.datepicker');
|
||||||
|
|
||||||
$buff .=
|
$buff .=
|
||||||
'<input type="hidden" name="'.$column_name.'" value="'.$value.'" />'.
|
'<input type="hidden" name="' . $column_name . '" value="' . $value . '" />' .
|
||||||
'<input type="text" id="date_'.$column_name.'" value="'.zdate($value,'Y-m-d').'" class="date" /> <input type="button" value="' . Context::getLang('cmd_delete') . '" id="dateRemover_' . $column_name . '" />'."\n".
|
'<input type="text" id="date_' . $column_name . '" value="' . zdate($value, 'Y-m-d') . '" class="date" /> <input type="button" value="' . Context::getLang('cmd_delete') . '" id="dateRemover_' . $column_name . '" />' . "\n" .
|
||||||
'<script>'."\n".
|
'<script>' . "\n" .
|
||||||
'(function($){'."\n".
|
'(function($){' . "\n" .
|
||||||
' $(function(){'."\n".
|
' $(function(){' . "\n" .
|
||||||
' var option = { dateFormat: "yy-mm-dd", changeMonth:true, changeYear:true, gotoCurrent: false,yearRange:\'-100:+10\', onSelect:function(){'."\n".
|
' var option = { dateFormat: "yy-mm-dd", changeMonth:true, changeYear:true, gotoCurrent: false,yearRange:\'-100:+10\', onSelect:function(){' . "\n" .
|
||||||
' $(this).prev(\'input[type="hidden"]\').val(this.value.replace(/-/g,""))}'."\n".
|
' $(this).prev(\'input[type="hidden"]\').val(this.value.replace(/-/g,""))}' . "\n" .
|
||||||
' };'."\n".
|
' };' . "\n" .
|
||||||
' $.extend(option,$.datepicker.regional[\''.Context::getLangType().'\']);'."\n".
|
' $.extend(option,$.datepicker.regional[\'' . Context::getLangType() . '\']);' . "\n" .
|
||||||
' $("#date_'.$column_name.'").datepicker(option);'."\n".
|
' $("#date_' . $column_name . '").datepicker(option);' . "\n" .
|
||||||
' $("#dateRemover_' . $column_name . '").click(function(){' . "\n" .
|
' $("#dateRemover_' . $column_name . '").click(function(){' . "\n" .
|
||||||
' $(this).siblings("input").val("");' . "\n" .
|
' $(this).siblings("input").val("");' . "\n" .
|
||||||
' return false;' . "\n" .
|
' return false;' . "\n" .
|
||||||
' })' . "\n" .
|
' })' . "\n" .
|
||||||
' });'."\n".
|
' });' . "\n" .
|
||||||
'})(jQuery);'."\n".
|
'})(jQuery);' . "\n" .
|
||||||
'</script>';
|
'</script>';
|
||||||
break;
|
break;
|
||||||
// address
|
// address
|
||||||
|
|
@ -381,33 +476,35 @@ class ExtraItem
|
||||||
Context::loadJavascriptPlugin('ui.krzip');
|
Context::loadJavascriptPlugin('ui.krzip');
|
||||||
|
|
||||||
$buff .=
|
$buff .=
|
||||||
'<div id="addr_searched_'.$column_name.'" style="display:'.($value[0]?'block':'none').';">'.
|
'<div id="addr_searched_' . $column_name . '" style="display:' . ($value[0] ? 'block' : 'none') . ';">' .
|
||||||
'<input type="text" readonly="readonly" name="'.$column_name.'[]" value="'.$value[0].'" class="address" />'.
|
'<input type="text" readonly="readonly" name="' . $column_name . '[]" value="' . $value[0] . '" class="address" />' .
|
||||||
'<a href="#" onclick="doShowKrZipSearch(this, \''.$column_name.'\'); return false;" class="button red"><span>'.Context::getLang('cmd_cancel').'</span></a>'.
|
'<a href="#" onclick="doShowKrZipSearch(this, \'' . $column_name . '\'); return false;" class="button red"><span>' . Context::getLang('cmd_cancel') . '</span></a>' .
|
||||||
'</div>'.
|
'</div>' .
|
||||||
|
'<div id="addr_list_' . $column_name . '" style="display:none;">' .
|
||||||
'<div id="addr_list_'.$column_name.'" style="display:none;">'.
|
'<select name="addr_list_' . $column_name . '"></select>' .
|
||||||
'<select name="addr_list_'.$column_name.'"></select>'.
|
'<a href="#" onclick="doSelectKrZip(this, \'' . $column_name . '\'); return false;" class="button blue"><span>' . Context::getLang('cmd_select') . '</span></a>' .
|
||||||
'<a href="#" onclick="doSelectKrZip(this, \''.$column_name.'\'); return false;" class="button blue"><span>'.Context::getLang('cmd_select').'</span></a>'.
|
'<a href="#" onclick="doHideKrZipList(this, \'' . $column_name . '\'); return false;" class="button red"><span>' . Context::getLang('cmd_cancel') . '</span></a>' .
|
||||||
'<a href="#" onclick="doHideKrZipList(this, \''.$column_name.'\'); return false;" class="button red"><span>'.Context::getLang('cmd_cancel').'</span></a>'.
|
'</div>' .
|
||||||
'</div>'.
|
'<div id="addr_search_' . $column_name . '" style="display:' . ($value[0] ? 'none' : 'block') . '">' .
|
||||||
|
'<input type="text" name="addr_search_' . $column_name . '" class="address" value="" />' .
|
||||||
'<div id="addr_search_'.$column_name.'" style="display:'.($value[0]?'none':'block').'">'.
|
'<a href="#" onclick="doSearchKrZip(this, \'' . $column_name . '\'); return false;" class="button green"><span>' . Context::getLang('cmd_search') . '</span></a>' .
|
||||||
'<input type="text" name="addr_search_'.$column_name.'" class="address" value="" />'.
|
'</div>' .
|
||||||
'<a href="#" onclick="doSearchKrZip(this, \''.$column_name.'\'); return false;" class="button green"><span>'.Context::getLang('cmd_search').'</span></a>'.
|
'<input type="text" name="' . $column_name . '[]" value="' . htmlspecialchars($value[1]) . '" class="address" />' .
|
||||||
'</div>'.
|
|
||||||
|
|
||||||
'<input type="text" name="'.$column_name.'[]" value="'.htmlspecialchars($value[1]).'" class="address" />'.
|
|
||||||
'';
|
'';
|
||||||
break;
|
break;
|
||||||
// General text
|
// General text
|
||||||
default :
|
default :
|
||||||
$buff .=' <input type="text" name="'.$column_name.'" value="'.($value ? $value : $default).'" class="text" />';
|
$buff .=' <input type="text" name="' . $column_name . '" value="' . ($value ? $value : $default) . '" class="text" />';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if($this->desc) $buff .= '<p>'.$this->desc.'</p>';
|
if($this->desc)
|
||||||
|
{
|
||||||
|
$buff .= '<p>' . $this->desc . '</p>';
|
||||||
|
}
|
||||||
|
|
||||||
return $buff;
|
return $buff;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/* End of file ExtraVar.class.php */
|
/* End of file ExtraVar.class.php */
|
||||||
/* Location: ./classes/extravar/ExtraVar.class.php */
|
/* Location: ./classes/extravar/ExtraVar.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains methods for accessing file system
|
* Contains methods for accessing file system
|
||||||
*
|
*
|
||||||
|
|
@ -6,6 +7,7 @@
|
||||||
*/
|
*/
|
||||||
class FileHandler
|
class FileHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes path of target file, directory into absolute path
|
* Changes path of target file, directory into absolute path
|
||||||
*
|
*
|
||||||
|
|
@ -15,7 +17,10 @@ class FileHandler
|
||||||
function getRealPath($source)
|
function getRealPath($source)
|
||||||
{
|
{
|
||||||
$temp = explode('/', $source);
|
$temp = explode('/', $source);
|
||||||
if($temp[0] == '.') $source = _XE_PATH_.substr($source, 2);
|
if($temp[0] == '.')
|
||||||
|
{
|
||||||
|
$source = _XE_PATH_ . substr($source, 2);
|
||||||
|
}
|
||||||
return $source;
|
return $source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,35 +35,60 @@ class FileHandler
|
||||||
* @param string $type If set as 'force'. Even if the file exists in target, the file is copied.
|
* @param string $type If set as 'force'. Even if the file exists in target, the file is copied.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function copyDir($source_dir, $target_dir, $filter=null,$type=null)
|
function copyDir($source_dir, $target_dir, $filter = null, $type = null)
|
||||||
{
|
{
|
||||||
$source_dir = FileHandler::getRealPath($source_dir);
|
$source_dir = FileHandler::getRealPath($source_dir);
|
||||||
$target_dir = FileHandler::getRealPath($target_dir);
|
$target_dir = FileHandler::getRealPath($target_dir);
|
||||||
if(!is_dir($source_dir)) return false;
|
if(!is_dir($source_dir))
|
||||||
// generate when no target exists
|
{
|
||||||
if(!file_exists($target_dir)) FileHandler::makeDir($target_dir);
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(substr($source_dir, -1) != '/') $source_dir .= '/';
|
// generate when no target exists
|
||||||
if(substr($target_dir, -1) != '/') $target_dir .= '/';
|
if(!file_exists($target_dir))
|
||||||
|
{
|
||||||
|
FileHandler::makeDir($target_dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(substr($source_dir, -1) != '/')
|
||||||
|
{
|
||||||
|
$source_dir .= '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(substr($target_dir, -1) != '/')
|
||||||
|
{
|
||||||
|
$target_dir .= '/';
|
||||||
|
}
|
||||||
|
|
||||||
$oDir = dir($source_dir);
|
$oDir = dir($source_dir);
|
||||||
while($file = $oDir->read())
|
while($file = $oDir->read())
|
||||||
{
|
{
|
||||||
if(substr($file,0,1)=='.') continue;
|
if(substr($file, 0, 1) == '.')
|
||||||
if($filter && preg_match($filter, $file)) continue;
|
|
||||||
if(is_dir($source_dir.$file))
|
|
||||||
{
|
{
|
||||||
FileHandler::copyDir($source_dir.$file,$target_dir.$file,$type);
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($filter && preg_match($filter, $file))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(is_dir($source_dir . $file))
|
||||||
|
{
|
||||||
|
FileHandler::copyDir($source_dir . $file, $target_dir . $file, $type);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if($type == 'force')
|
if($type == 'force')
|
||||||
{
|
{
|
||||||
@unlink($target_dir.$file);
|
@unlink($target_dir . $file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!file_exists($target_dir.$file)) @copy($source_dir.$file,$target_dir.$file);
|
if(!file_exists($target_dir . $file))
|
||||||
|
{
|
||||||
|
@copy($source_dir . $file, $target_dir . $file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -72,15 +102,24 @@ class FileHandler
|
||||||
* @param string $force Y: overwrite
|
* @param string $force Y: overwrite
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function copyFile($source, $target, $force='Y')
|
function copyFile($source, $target, $force = 'Y')
|
||||||
{
|
{
|
||||||
setlocale(LC_CTYPE, 'en_US.UTF8', 'ko_KR.UTF8');
|
setlocale(LC_CTYPE, 'en_US.UTF8', 'ko_KR.UTF8');
|
||||||
$source = FileHandler::getRealPath($source);
|
$source = FileHandler::getRealPath($source);
|
||||||
$target_dir = FileHandler::getRealPath(dirname($target));
|
$target_dir = FileHandler::getRealPath(dirname($target));
|
||||||
$target = basename($target);
|
$target = basename($target);
|
||||||
if(!file_exists($target_dir)) FileHandler::makeDir($target_dir);
|
|
||||||
if($force=='Y') @unlink($target_dir.'/'.$target);
|
if(!file_exists($target_dir))
|
||||||
@copy($source, $target_dir.'/'.$target);
|
{
|
||||||
|
FileHandler::makeDir($target_dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($force == 'Y')
|
||||||
|
{
|
||||||
|
@unlink($target_dir . '/' . $target);
|
||||||
|
}
|
||||||
|
|
||||||
|
@copy($source, $target_dir . '/' . $target);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -93,24 +132,18 @@ class FileHandler
|
||||||
{
|
{
|
||||||
$file_name = FileHandler::getRealPath($file_name);
|
$file_name = FileHandler::getRealPath($file_name);
|
||||||
|
|
||||||
if(!file_exists($file_name)) return;
|
if(!file_exists($file_name))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$filesize = filesize($file_name);
|
$filesize = filesize($file_name);
|
||||||
if($filesize<1) return;
|
if($filesize < 1)
|
||||||
|
|
||||||
if(function_exists('file_get_contents')) return @file_get_contents($file_name);
|
|
||||||
|
|
||||||
$fp = fopen($file_name, "r");
|
|
||||||
$buff = '';
|
|
||||||
if($fp)
|
|
||||||
{
|
{
|
||||||
while(!feof($fp) && strlen($buff)<=$filesize)
|
return;
|
||||||
{
|
|
||||||
$str = fgets($fp, 1024);
|
|
||||||
$buff .= $str;
|
|
||||||
}
|
}
|
||||||
fclose($fp);
|
|
||||||
}
|
return @file_get_contents($file_name);
|
||||||
return $buff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -127,13 +160,22 @@ class FileHandler
|
||||||
|
|
||||||
$pathinfo = pathinfo($file_name);
|
$pathinfo = pathinfo($file_name);
|
||||||
$path = $pathinfo['dirname'];
|
$path = $pathinfo['dirname'];
|
||||||
if(!is_dir($path)) FileHandler::makeDir($path);
|
if(!is_dir($path))
|
||||||
|
{
|
||||||
|
FileHandler::makeDir($path);
|
||||||
|
}
|
||||||
|
|
||||||
$mode = strtolower($mode);
|
$mode = strtolower($mode);
|
||||||
if($mode != "a") $mode = "w";
|
if($mode == 'a')
|
||||||
if(@!$fp = fopen($file_name,$mode)) return false;
|
{
|
||||||
fwrite($fp, $buff);
|
$flags = FILE_APPEND;
|
||||||
fclose($fp);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$flags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@file_put_contents($file_name, $buff, $flags);
|
||||||
@chmod($file_name, 0644);
|
@chmod($file_name, 0644);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -212,20 +254,42 @@ class FileHandler
|
||||||
{
|
{
|
||||||
$path = FileHandler::getRealPath($path);
|
$path = FileHandler::getRealPath($path);
|
||||||
|
|
||||||
if(substr($path,-1)!='/') $path .= '/';
|
if(substr($path, -1) != '/')
|
||||||
if(!is_dir($path)) return array();
|
{
|
||||||
|
$path .= '/';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!is_dir($path))
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
$oDir = dir($path);
|
$oDir = dir($path);
|
||||||
while($file = $oDir->read())
|
while($file = $oDir->read())
|
||||||
{
|
{
|
||||||
if(substr($file,0,1)=='.') continue;
|
if(substr($file, 0, 1) == '.')
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if($filter && !preg_match($filter, $file)) continue;
|
if($filter && !preg_match($filter, $file))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if($to_lower) $file = strtolower($file);
|
if($to_lower)
|
||||||
|
{
|
||||||
|
$file = strtolower($file);
|
||||||
|
}
|
||||||
|
|
||||||
if($filter) $file = preg_replace($filter, '$1', $file);
|
if($filter)
|
||||||
else $file = $file;
|
{
|
||||||
|
$file = preg_replace($filter, '$1', $file);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$file = $file;
|
||||||
|
}
|
||||||
|
|
||||||
if($concat_prefix)
|
if($concat_prefix)
|
||||||
{
|
{
|
||||||
|
|
@ -234,7 +298,11 @@ class FileHandler
|
||||||
|
|
||||||
$output[] = $file;
|
$output[] = $file;
|
||||||
}
|
}
|
||||||
if(!$output) return array();
|
|
||||||
|
if(!$output)
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
@ -257,13 +325,25 @@ class FileHandler
|
||||||
$ftp_info = Context::getFTPInfo();
|
$ftp_info = Context::getFTPInfo();
|
||||||
if($oFtp == null)
|
if($oFtp == null)
|
||||||
{
|
{
|
||||||
if(!Context::isFTPRegisted()) return;
|
if(!Context::isFTPRegisted())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
require_once(_XE_PATH_.'libs/ftp.class.php');
|
require_once(_XE_PATH_ . 'libs/ftp.class.php');
|
||||||
$oFtp = new ftp();
|
$oFtp = new ftp();
|
||||||
if(!$ftp_info->ftp_host) $ftp_info->ftp_host = "127.0.0.1";
|
if(!$ftp_info->ftp_host)
|
||||||
if(!$ftp_info->ftp_port) $ftp_info->ftp_port = 21;
|
{
|
||||||
if(!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) return;
|
$ftp_info->ftp_host = "127.0.0.1";
|
||||||
|
}
|
||||||
|
if(!$ftp_info->ftp_port)
|
||||||
|
{
|
||||||
|
$ftp_info->ftp_port = 21;
|
||||||
|
}
|
||||||
|
if(!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password))
|
if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password))
|
||||||
{
|
{
|
||||||
$oFtp->ftp_quit();
|
$oFtp->ftp_quit();
|
||||||
|
|
@ -271,24 +351,31 @@ class FileHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$ftp_path = $ftp_info->ftp_root_path;
|
$ftp_path = $ftp_info->ftp_root_path;
|
||||||
if(!$ftp_path) $ftp_path = "/";
|
if(!$ftp_path)
|
||||||
|
{
|
||||||
|
$ftp_path = "/";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$path_string = str_replace(_XE_PATH_,'',$path_string);
|
$path_string = str_replace(_XE_PATH_, '', $path_string);
|
||||||
$path_list = explode('/', $path_string);
|
$path_list = explode('/', $path_string);
|
||||||
|
|
||||||
$path = _XE_PATH_;
|
$path = _XE_PATH_;
|
||||||
for($i=0;$i<count($path_list);$i++)
|
for($i = 0; $i < count($path_list); $i++)
|
||||||
{
|
{
|
||||||
if(!$path_list[$i]) continue;
|
if(!$path_list[$i])
|
||||||
$path .= $path_list[$i].'/';
|
{
|
||||||
$ftp_path .= $path_list[$i].'/';
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path .= $path_list[$i] . '/';
|
||||||
|
$ftp_path .= $path_list[$i] . '/';
|
||||||
if(!is_dir($path))
|
if(!is_dir($path))
|
||||||
{
|
{
|
||||||
if(ini_get('safe_mode'))
|
if(ini_get('safe_mode'))
|
||||||
{
|
{
|
||||||
$oFtp->ftp_mkdir($ftp_path);
|
$oFtp->ftp_mkdir($ftp_path);
|
||||||
$oFtp->ftp_site("CHMOD 777 ".$ftp_path);
|
$oFtp->ftp_site("CHMOD 777 " . $ftp_path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -310,19 +397,23 @@ class FileHandler
|
||||||
function removeDir($path)
|
function removeDir($path)
|
||||||
{
|
{
|
||||||
$path = FileHandler::getRealPath($path);
|
$path = FileHandler::getRealPath($path);
|
||||||
if(!is_dir($path)) return;
|
if(!is_dir($path))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$directory = dir($path);
|
$directory = dir($path);
|
||||||
while($entry = $directory->read())
|
while($entry = $directory->read())
|
||||||
{
|
{
|
||||||
if ($entry != "." && $entry != "..")
|
if($entry != "." && $entry != "..")
|
||||||
{
|
{
|
||||||
if (is_dir($path."/".$entry))
|
if(is_dir($path . "/" . $entry))
|
||||||
{
|
{
|
||||||
FileHandler::removeDir($path."/".$entry);
|
FileHandler::removeDir($path . "/" . $entry);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@unlink($path."/".$entry);
|
@unlink($path . "/" . $entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -341,18 +432,30 @@ class FileHandler
|
||||||
$item_cnt = 0;
|
$item_cnt = 0;
|
||||||
|
|
||||||
$path = FileHandler::getRealPath($path);
|
$path = FileHandler::getRealPath($path);
|
||||||
if(!is_dir($path)) return;
|
if(!is_dir($path))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$directory = dir($path);
|
$directory = dir($path);
|
||||||
while($entry = $directory->read())
|
while($entry = $directory->read())
|
||||||
{
|
{
|
||||||
if ($entry == "." || $entry == "..") continue;
|
if($entry == "." || $entry == "..")
|
||||||
if (is_dir($path."/".$entry)) $item_cnt = FileHandler::removeBlankDir($path.'/'.$entry);
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(is_dir($path . "/" . $entry))
|
||||||
|
{
|
||||||
|
$item_cnt = FileHandler::removeBlankDir($path . '/' . $entry);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$directory->close();
|
$directory->close();
|
||||||
|
|
||||||
if($item_cnt < 1) @rmdir($path);
|
if($item_cnt < 1)
|
||||||
|
{
|
||||||
|
@rmdir($path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove files in the target directory
|
* Remove files in the target directory
|
||||||
|
|
@ -365,19 +468,23 @@ class FileHandler
|
||||||
function removeFilesInDir($path)
|
function removeFilesInDir($path)
|
||||||
{
|
{
|
||||||
$path = FileHandler::getRealPath($path);
|
$path = FileHandler::getRealPath($path);
|
||||||
if(!is_dir($path)) return;
|
if(!is_dir($path))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$directory = dir($path);
|
$directory = dir($path);
|
||||||
while($entry = $directory->read())
|
while($entry = $directory->read())
|
||||||
{
|
{
|
||||||
if ($entry != "." && $entry != "..")
|
if($entry != "." && $entry != "..")
|
||||||
{
|
{
|
||||||
if (is_dir($path."/".$entry))
|
if(is_dir($path . "/" . $entry))
|
||||||
{
|
{
|
||||||
FileHandler::removeFilesInDir($path."/".$entry);
|
FileHandler::removeFilesInDir($path . "/" . $entry);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@unlink($path."/".$entry);
|
@unlink($path . "/" . $entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -393,11 +500,27 @@ class FileHandler
|
||||||
*/
|
*/
|
||||||
function filesize($size)
|
function filesize($size)
|
||||||
{
|
{
|
||||||
if(!$size) return '0Byte';
|
if(!$size)
|
||||||
if($size === 1) return '1Byte';
|
{
|
||||||
if($size < 1024) return $size.'Bytes';
|
return '0Byte';
|
||||||
if($size >= 1024 && $size < 1024*1024) return sprintf("%0.1fKB",$size / 1024);
|
}
|
||||||
return sprintf("%0.2fMB",$size / (1024*1024));
|
|
||||||
|
if($size === 1)
|
||||||
|
{
|
||||||
|
return '1Byte';
|
||||||
|
}
|
||||||
|
|
||||||
|
if($size < 1024)
|
||||||
|
{
|
||||||
|
return $size . 'Bytes';
|
||||||
|
}
|
||||||
|
|
||||||
|
if($size >= 1024 && $size < 1024 * 1024)
|
||||||
|
{
|
||||||
|
return sprintf("%0.1fKB", $size / 1024);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sprintf("%0.2fMB", $size / (1024 * 1024));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -417,32 +540,7 @@ class FileHandler
|
||||||
*/
|
*/
|
||||||
function getRemoteResource($url, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array())
|
function getRemoteResource($url, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array())
|
||||||
{
|
{
|
||||||
if(version_compare(PHP_VERSION, '5.0.0', '>='))
|
try
|
||||||
{
|
|
||||||
return include _XE_PATH_ . 'classes/file/getRemoteResourcePHP5.php';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return FileHandler::_getRemoteResource($url, $boyd, $timeout, $mehtod, $conent_type, $headers, $cookies, $post_data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return remote file's content via HTTP
|
|
||||||
*
|
|
||||||
* If the target is moved (when return code is 300~399), this function follows the location specified response header.
|
|
||||||
*
|
|
||||||
* @param string $url The address of the target file
|
|
||||||
* @param string $body HTTP request body
|
|
||||||
* @param int $timeout Connection timeout
|
|
||||||
* @param string $method GET/POST
|
|
||||||
* @param string $content_type Content type header of HTTP request
|
|
||||||
* @param string[] $headers Headers key vaule array.
|
|
||||||
* @param string[] $cookies Cookies key value array.
|
|
||||||
* @param string $post_data Request arguments array for POST method
|
|
||||||
* @return string If success, the content of the target file. Otherwise: none
|
|
||||||
*/
|
|
||||||
function _getRemoteResource($url, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array())
|
|
||||||
{
|
{
|
||||||
requirePear();
|
requirePear();
|
||||||
require_once('HTTP/Request.php');
|
require_once('HTTP/Request.php');
|
||||||
|
|
@ -453,7 +551,7 @@ class FileHandler
|
||||||
$oRequest = new HTTP_Request(__PROXY_SERVER__);
|
$oRequest = new HTTP_Request(__PROXY_SERVER__);
|
||||||
$oRequest->setMethod('POST');
|
$oRequest->setMethod('POST');
|
||||||
$oRequest->_timeout = $timeout;
|
$oRequest->_timeout = $timeout;
|
||||||
$oRequest->addPostData('arg', serialize(array('Destination'=>$url, 'method'=>$method, 'body'=>$body, 'content_type'=>$content_type, "headers"=>$headers, "post_data"=>$post_data)));
|
$oRequest->addPostData('arg', serialize(array('Destination' => $url, 'method' => $method, 'body' => $body, 'content_type' => $content_type, "headers" => $headers, "post_data" => $post_data)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -479,10 +577,13 @@ class FileHandler
|
||||||
$oRequest->addPostData($key, $val);
|
$oRequest->addPostData($key, $val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!$content_type) $oRequest->addHeader('Content-Type', 'text/html');
|
if(!$content_type)
|
||||||
else $oRequest->addHeader('Content-Type', $content_type);
|
$oRequest->addHeader('Content-Type', 'text/html');
|
||||||
|
else
|
||||||
|
$oRequest->addHeader('Content-Type', $content_type);
|
||||||
$oRequest->setMethod($method);
|
$oRequest->setMethod($method);
|
||||||
if($body) $oRequest->setBody($body);
|
if($body)
|
||||||
|
$oRequest->setBody($body);
|
||||||
|
|
||||||
$oRequest->_timeout = $timeout;
|
$oRequest->_timeout = $timeout;
|
||||||
}
|
}
|
||||||
|
|
@ -505,10 +606,16 @@ class FileHandler
|
||||||
return FileHandler::getRemoteResource($header['location'], $body, $timeout, $method, $content_type, $headers, $cookies, $post_data);
|
return FileHandler::getRemoteResource($header['location'], $body, $timeout, $method, $content_type, $headers, $cookies, $post_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($code != 200) return;
|
if($code != 200)
|
||||||
|
return;
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
catch(Exception $e)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves remote file, then stores it into target path.
|
* Retrieves remote file, then stores it into target path.
|
||||||
|
|
@ -525,10 +632,13 @@ class FileHandler
|
||||||
function getRemoteFile($url, $target_filename, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array())
|
function getRemoteFile($url, $target_filename, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array())
|
||||||
{
|
{
|
||||||
$body = FileHandler::getRemoteResource($url, $body, $timeout, $method, $content_type, $headers);
|
$body = FileHandler::getRemoteResource($url, $body, $timeout, $method, $content_type, $headers);
|
||||||
if(!$body) return false;
|
if(!$body)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
$target_filename = FileHandler::getRealPath($target_filename);
|
$target_filename = FileHandler::getRealPath($target_filename);
|
||||||
FileHandler::writeFile($target_filename, $body);
|
FileHandler::writeFile($target_filename, $body);
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -542,10 +652,22 @@ class FileHandler
|
||||||
{
|
{
|
||||||
$val = trim($val);
|
$val = trim($val);
|
||||||
$last = strtolower(substr($val, -1));
|
$last = strtolower(substr($val, -1));
|
||||||
if($last == 'g') $val *= 1024*1024*1024;
|
if($last == 'g')
|
||||||
else if($last == 'm') $val *= 1024*1024;
|
{
|
||||||
else if($last == 'k') $val *= 1024;
|
$val *= 1024 * 1024 * 1024;
|
||||||
else $val *= 1;
|
}
|
||||||
|
else if($last == 'm')
|
||||||
|
{
|
||||||
|
$val *= 1024 * 1024;
|
||||||
|
}
|
||||||
|
else if($last == 'k')
|
||||||
|
{
|
||||||
|
$val *= 1024;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$val *= 1;
|
||||||
|
}
|
||||||
|
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
@ -558,15 +680,25 @@ class FileHandler
|
||||||
*/
|
*/
|
||||||
function checkMemoryLoadImage(&$imageInfo)
|
function checkMemoryLoadImage(&$imageInfo)
|
||||||
{
|
{
|
||||||
if(!function_exists('memory_get_usage')) return true;
|
if(!function_exists('memory_get_usage'))
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
$K64 = 65536;
|
$K64 = 65536;
|
||||||
$TWEAKFACTOR = 2.0;
|
$TWEAKFACTOR = 2.0;
|
||||||
$channels = $imageInfo['channels'];
|
$channels = $imageInfo['channels'];
|
||||||
if(!$channels) $channels = 6; //for png
|
if(!$channels)
|
||||||
$memoryNeeded = round( ($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $channels / 8 + $K64 ) * $TWEAKFACTOR );
|
{
|
||||||
|
$channels = 6; //for png
|
||||||
|
}
|
||||||
|
$memoryNeeded = round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $channels / 8 + $K64 ) * $TWEAKFACTOR);
|
||||||
$availableMemory = FileHandler::returnBytes(ini_get('memory_limit')) - memory_get_usage();
|
$availableMemory = FileHandler::returnBytes(ini_get('memory_limit')) - memory_get_usage();
|
||||||
if($availableMemory < $memoryNeeded) return false;
|
if($availableMemory < $memoryNeeded)
|
||||||
return true;
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -585,16 +717,31 @@ class FileHandler
|
||||||
$source_file = FileHandler::getRealPath($source_file);
|
$source_file = FileHandler::getRealPath($source_file);
|
||||||
$target_file = FileHandler::getRealPath($target_file);
|
$target_file = FileHandler::getRealPath($target_file);
|
||||||
|
|
||||||
if(!file_exists($source_file)) return;
|
if(!file_exists($source_file))
|
||||||
if(!$resize_width) $resize_width = 100;
|
{
|
||||||
if(!$resize_height) $resize_height = $resize_width;
|
return;
|
||||||
|
}
|
||||||
|
if(!$resize_width)
|
||||||
|
{
|
||||||
|
$resize_width = 100;
|
||||||
|
}
|
||||||
|
if(!$resize_height)
|
||||||
|
{
|
||||||
|
$resize_height = $resize_width;
|
||||||
|
}
|
||||||
|
|
||||||
// retrieve source image's information
|
// retrieve source image's information
|
||||||
$imageInfo = getimagesize($source_file);
|
$imageInfo = getimagesize($source_file);
|
||||||
if(!FileHandler::checkMemoryLoadImage($imageInfo)) return false;
|
if(!FileHandler::checkMemoryLoadImage($imageInfo))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
list($width, $height, $type, $attrs) = $imageInfo;
|
list($width, $height, $type, $attrs) = $imageInfo;
|
||||||
|
|
||||||
if($width<1 || $height<1) return;
|
if($width < 1 || $height < 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch($type)
|
switch($type)
|
||||||
{
|
{
|
||||||
|
|
@ -616,62 +763,116 @@ class FileHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
// if original image is larger than specified size to resize, calculate the ratio
|
// if original image is larger than specified size to resize, calculate the ratio
|
||||||
if($resize_width > 0 && $width >= $resize_width) $width_per = $resize_width / $width;
|
if($resize_width > 0 && $width >= $resize_width)
|
||||||
else $width_per = 1;
|
{
|
||||||
|
$width_per = $resize_width / $width;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$width_per = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if($resize_height>0 && $height >= $resize_height) $height_per = $resize_height / $height;
|
if($resize_height > 0 && $height >= $resize_height)
|
||||||
else $height_per = 1;
|
{
|
||||||
|
$height_per = $resize_height / $height;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$height_per = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if($thumbnail_type == 'ratio')
|
if($thumbnail_type == 'ratio')
|
||||||
{
|
{
|
||||||
if($width_per>$height_per) $per = $height_per;
|
if($width_per > $height_per)
|
||||||
else $per = $width_per;
|
{
|
||||||
|
$per = $height_per;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$per = $width_per;
|
||||||
|
}
|
||||||
$resize_width = $width * $per;
|
$resize_width = $width * $per;
|
||||||
$resize_height = $height * $per;
|
$resize_height = $height * $per;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if($width_per < $height_per) $per = $height_per;
|
if($width_per < $height_per)
|
||||||
else $per = $width_per;
|
{
|
||||||
|
$per = $height_per;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$per = $width_per;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$per) $per = 1;
|
if(!$per)
|
||||||
|
{
|
||||||
|
$per = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// get type of target file
|
// get type of target file
|
||||||
if(!$target_type) $target_type = $type;
|
if(!$target_type)
|
||||||
|
{
|
||||||
|
$target_type = $type;
|
||||||
|
}
|
||||||
$target_type = strtolower($target_type);
|
$target_type = strtolower($target_type);
|
||||||
|
|
||||||
// create temporary image with target size
|
// create temporary image with target size
|
||||||
if(function_exists('imagecreatetruecolor')) $thumb = imagecreatetruecolor($resize_width, $resize_height);
|
if(function_exists('imagecreatetruecolor'))
|
||||||
else if(function_exists('imagecreate')) $thumb = imagecreate($resize_width, $resize_height);
|
{
|
||||||
else return false;
|
$thumb = imagecreatetruecolor($resize_width, $resize_height);
|
||||||
if(!$thumb) return false;
|
}
|
||||||
|
else if(function_exists('imagecreate'))
|
||||||
|
{
|
||||||
|
$thumb = imagecreate($resize_width, $resize_height);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if(!$thumb)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
$white = imagecolorallocate($thumb, 255,255,255);
|
$white = imagecolorallocate($thumb, 255, 255, 255);
|
||||||
imagefilledrectangle($thumb,0,0,$resize_width-1,$resize_height-1,$white);
|
imagefilledrectangle($thumb, 0, 0, $resize_width - 1, $resize_height - 1, $white);
|
||||||
|
|
||||||
// create temporary image having original type
|
// create temporary image having original type
|
||||||
switch($type)
|
switch($type)
|
||||||
{
|
{
|
||||||
case 'gif' :
|
case 'gif' :
|
||||||
if(!function_exists('imagecreatefromgif')) return false;
|
if(!function_exists('imagecreatefromgif'))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
$source = @imagecreatefromgif($source_file);
|
$source = @imagecreatefromgif($source_file);
|
||||||
break;
|
break;
|
||||||
// jpg
|
// jpg
|
||||||
case 'jpeg' :
|
case 'jpeg' :
|
||||||
case 'jpg' :
|
case 'jpg' :
|
||||||
if(!function_exists('imagecreatefromjpeg')) return false;
|
if(!function_exists('imagecreatefromjpeg'))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
$source = @imagecreatefromjpeg($source_file);
|
$source = @imagecreatefromjpeg($source_file);
|
||||||
break;
|
break;
|
||||||
// png
|
// png
|
||||||
case 'png' :
|
case 'png' :
|
||||||
if(!function_exists('imagecreatefrompng')) return false;
|
if(!function_exists('imagecreatefrompng'))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
$source = @imagecreatefrompng($source_file);
|
$source = @imagecreatefrompng($source_file);
|
||||||
break;
|
break;
|
||||||
// bmp
|
// bmp
|
||||||
case 'wbmp' :
|
case 'wbmp' :
|
||||||
case 'bmp' :
|
case 'bmp' :
|
||||||
if(!function_exists('imagecreatefromwbmp')) return false;
|
if(!function_exists('imagecreatefromwbmp'))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
$source = @imagecreatefromwbmp($source_file);
|
$source = @imagecreatefromwbmp($source_file);
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
|
|
@ -679,13 +880,13 @@ class FileHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
// resize original image and put it into temporary image
|
// resize original image and put it into temporary image
|
||||||
$new_width = (int)($width * $per);
|
$new_width = (int) ($width * $per);
|
||||||
$new_height = (int)($height * $per);
|
$new_height = (int) ($height * $per);
|
||||||
|
|
||||||
if($thumbnail_type == 'crop')
|
if($thumbnail_type == 'crop')
|
||||||
{
|
{
|
||||||
$x = (int)($resize_width/2 - $new_width/2);
|
$x = (int) ($resize_width / 2 - $new_width / 2);
|
||||||
$y = (int)($resize_height/2 - $new_height/2);
|
$y = (int) ($resize_height / 2 - $new_height / 2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -695,34 +896,58 @@ class FileHandler
|
||||||
|
|
||||||
if($source)
|
if($source)
|
||||||
{
|
{
|
||||||
if(function_exists('imagecopyresampled')) imagecopyresampled($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height);
|
if(function_exists('imagecopyresampled'))
|
||||||
else imagecopyresized($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height);
|
{
|
||||||
|
imagecopyresampled($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
imagecopyresized($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
else return false;
|
|
||||||
|
|
||||||
// create directory
|
// create directory
|
||||||
$path = dirname($target_file);
|
$path = dirname($target_file);
|
||||||
if(!is_dir($path)) FileHandler::makeDir($path);
|
if(!is_dir($path))
|
||||||
|
{
|
||||||
|
FileHandler::makeDir($path);
|
||||||
|
}
|
||||||
|
|
||||||
// write into the file
|
// write into the file
|
||||||
switch($target_type)
|
switch($target_type)
|
||||||
{
|
{
|
||||||
case 'gif' :
|
case 'gif' :
|
||||||
if(!function_exists('imagegif')) return false;
|
if(!function_exists('imagegif'))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
$output = imagegif($thumb, $target_file);
|
$output = imagegif($thumb, $target_file);
|
||||||
break;
|
break;
|
||||||
case 'jpeg' :
|
case 'jpeg' :
|
||||||
case 'jpg' :
|
case 'jpg' :
|
||||||
if(!function_exists('imagejpeg')) return false;
|
if(!function_exists('imagejpeg'))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
$output = imagejpeg($thumb, $target_file, 100);
|
$output = imagejpeg($thumb, $target_file, 100);
|
||||||
break;
|
break;
|
||||||
case 'png' :
|
case 'png' :
|
||||||
if(!function_exists('imagepng')) return false;
|
if(!function_exists('imagepng'))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
$output = imagepng($thumb, $target_file, 9);
|
$output = imagepng($thumb, $target_file, 9);
|
||||||
break;
|
break;
|
||||||
case 'wbmp' :
|
case 'wbmp' :
|
||||||
case 'bmp' :
|
case 'bmp' :
|
||||||
if(!function_exists('imagewbmp')) return false;
|
if(!function_exists('imagewbmp'))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
$output = imagewbmp($thumb, $target_file, 100);
|
$output = imagewbmp($thumb, $target_file, 100);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -730,10 +955,13 @@ class FileHandler
|
||||||
imagedestroy($thumb);
|
imagedestroy($thumb);
|
||||||
imagedestroy($source);
|
imagedestroy($source);
|
||||||
|
|
||||||
if(!$output) return false;
|
if(!$output)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
@chmod($target_file, 0644);
|
@chmod($target_file, 0644);
|
||||||
|
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -746,10 +974,19 @@ class FileHandler
|
||||||
function readIniFile($filename)
|
function readIniFile($filename)
|
||||||
{
|
{
|
||||||
$filename = FileHandler::getRealPath($filename);
|
$filename = FileHandler::getRealPath($filename);
|
||||||
if(!file_exists($filename)) return false;
|
if(!file_exists($filename))
|
||||||
$arr = parse_ini_file($filename, true);
|
{
|
||||||
if(is_array($arr) && count($arr)>0) return $arr;
|
return FALSE;
|
||||||
else return array();
|
}
|
||||||
|
$arr = parse_ini_file($filename, TRUE);
|
||||||
|
if(is_array($arr) && count($arr) > 0)
|
||||||
|
{
|
||||||
|
return $arr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -768,9 +1005,12 @@ class FileHandler
|
||||||
*/
|
*/
|
||||||
function writeIniFile($filename, $arr)
|
function writeIniFile($filename, $arr)
|
||||||
{
|
{
|
||||||
if(count($arr)==0) return false;
|
if(count($arr) == 0)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
FileHandler::writeFile($filename, FileHandler::_makeIniBuff($arr));
|
FileHandler::writeFile($filename, FileHandler::_makeIniBuff($arr));
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -787,16 +1027,16 @@ class FileHandler
|
||||||
// section
|
// section
|
||||||
if(is_array($val))
|
if(is_array($val))
|
||||||
{
|
{
|
||||||
$return .= sprintf("[%s]\n",$key);
|
$return .= sprintf("[%s]\n", $key);
|
||||||
foreach($val as $k => $v)
|
foreach($val as $k => $v)
|
||||||
{
|
{
|
||||||
$return .= sprintf("%s=\"%s\"\n",$k,$v);
|
$return .= sprintf("%s=\"%s\"\n", $k, $v);
|
||||||
}
|
}
|
||||||
// value
|
// value
|
||||||
}
|
}
|
||||||
else if(is_string($val) || is_int($val))
|
else if(is_string($val) || is_int($val))
|
||||||
{
|
{
|
||||||
$return .= sprintf("%s=\"%s\"\n",$key,$val);
|
$return .= sprintf("%s=\"%s\"\n", $key, $val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
|
|
@ -815,7 +1055,10 @@ class FileHandler
|
||||||
{
|
{
|
||||||
$pathinfo = pathinfo($filename);
|
$pathinfo = pathinfo($filename);
|
||||||
$path = $pathinfo['dirname'];
|
$path = $pathinfo['dirname'];
|
||||||
if(!is_dir($path)) FileHandler::makeDir($path);
|
if(!is_dir($path))
|
||||||
|
{
|
||||||
|
FileHandler::makeDir($path);
|
||||||
|
}
|
||||||
|
|
||||||
require_once("FileObject.class.php");
|
require_once("FileObject.class.php");
|
||||||
$file_object = new FileObject($file_name, $mode);
|
$file_object = new FileObject($file_name, $mode);
|
||||||
|
|
@ -832,7 +1075,7 @@ class FileHandler
|
||||||
{
|
{
|
||||||
return (is_readable($filename) && !!filesize($filename));
|
return (is_readable($filename) && !!filesize($filename));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
/* End of file FileHandler.class.php */
|
/* End of file FileHandler.class.php */
|
||||||
/* Location: ./classes/file/FileHandler.class.php */
|
/* Location: ./classes/file/FileHandler.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File abstraction class
|
* File abstraction class
|
||||||
*
|
*
|
||||||
|
|
@ -6,17 +7,18 @@
|
||||||
*/
|
*/
|
||||||
class FileObject extends Object
|
class FileObject extends Object
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File descriptor
|
* File descriptor
|
||||||
* @var resource
|
* @var resource
|
||||||
*/
|
*/
|
||||||
var $fp = null;
|
var $fp = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File path
|
* File path
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
var $path = null;
|
var $path = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File open mode
|
* File open mode
|
||||||
|
|
@ -33,7 +35,10 @@ class FileObject extends Object
|
||||||
*/
|
*/
|
||||||
function FileObject($path, $mode)
|
function FileObject($path, $mode)
|
||||||
{
|
{
|
||||||
if($path != null) $this->Open($path, $mode);
|
if($path != NULL)
|
||||||
|
{
|
||||||
|
$this->Open($path, $mode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -74,7 +79,6 @@ class FileObject extends Object
|
||||||
return fread($this->fp, $size);
|
return fread($this->fp, $size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write string to current file
|
* Write string to current file
|
||||||
*
|
*
|
||||||
|
|
@ -84,8 +88,14 @@ class FileObject extends Object
|
||||||
function write($str)
|
function write($str)
|
||||||
{
|
{
|
||||||
$len = strlen($str);
|
$len = strlen($str);
|
||||||
if(!$str || $len <= 0) return false;
|
if(!$str || $len <= 0)
|
||||||
if(!$this->fp) return false;
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if(!$this->fp)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
$written = fwrite($this->fp, $str);
|
$written = fwrite($this->fp, $str);
|
||||||
return $written;
|
return $written;
|
||||||
}
|
}
|
||||||
|
|
@ -101,18 +111,18 @@ class FileObject extends Object
|
||||||
*/
|
*/
|
||||||
function open($path, $mode)
|
function open($path, $mode)
|
||||||
{
|
{
|
||||||
if($this->fp != null)
|
if($this->fp != NULL)
|
||||||
{
|
{
|
||||||
$this->close();
|
$this->close();
|
||||||
}
|
}
|
||||||
$this->fp = fopen($path, $mode);
|
$this->fp = fopen($path, $mode);
|
||||||
if(! is_resource($this->fp) )
|
if(!is_resource($this->fp))
|
||||||
{
|
{
|
||||||
$this->fp = null;
|
$this->fp = NULL;
|
||||||
return false;
|
return FALSE;
|
||||||
}
|
}
|
||||||
$this->path = $path;
|
$this->path = $path;
|
||||||
return true;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -122,13 +132,13 @@ class FileObject extends Object
|
||||||
*/
|
*/
|
||||||
function getPath()
|
function getPath()
|
||||||
{
|
{
|
||||||
if($this->fp != null)
|
if($this->fp != NULL)
|
||||||
{
|
{
|
||||||
return $this->path;
|
return $this->path;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return null;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -139,13 +149,13 @@ class FileObject extends Object
|
||||||
*/
|
*/
|
||||||
function close()
|
function close()
|
||||||
{
|
{
|
||||||
if($this->fp != null)
|
if($this->fp != NULL)
|
||||||
{
|
{
|
||||||
fclose($this->fp);
|
fclose($this->fp);
|
||||||
$this->fp = null;
|
$this->fp = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
/* End of file FileObject.class.php */
|
/* End of file FileObject.class.php */
|
||||||
/* Location: ./classes/file/FileObject.class.php */
|
/* Location: ./classes/file/FileObject.class.php */
|
||||||
|
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
<?php
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return self::_getRemoteResource($url, $body, $timeout, $method, $content_type, $headers, $cookies, $post_data);
|
|
||||||
}
|
|
||||||
catch(Exception $e)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
/* End of file getRemoteResourcePHP5.php */
|
|
||||||
/* Location: ./classes/file/getRemoteResourcePHP5.php */
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue