| version 1.40, 2017/11/08 00:28:30 |
version 1.41, 2017/11/08 00:33:44 |
|
|
| * @access public |
* @access public |
| */ |
*/ |
| |
|
| /* $Platon: Metafox/lib/Platon.php,v 1.11 2015/01/20 15:20:17 igor Exp $ */ |
/* $Platon: phpPlatonLib/Platon/Platon.php,v 1.40 2017/11/08 00:28:30 nepto Exp $ */ |
| |
|
| class Platon |
class Platon |
| { |
{ |
|
|
| * @param boolean $temporary if such redirect is only temporary one |
* @param boolean $temporary if such redirect is only temporary one |
| * @todo implement HTML page redirecting if output was aleady sent |
* @todo implement HTML page redirecting if output was aleady sent |
| */ |
*/ |
| function redirect($where, $temporary = false) /* {{{ */ |
static function redirect($where, $temporary = false, $status_code = 301) /* {{{ */ |
| { |
{ |
| $url = ''; |
$url = ''; |
| if (! strncmp($where, "ftp://", 6) |
if (! strncmp($where, "ftp://", 6) |
|
|
| |
|
| header('Location: '.$url); |
header('Location: '.$url); |
| if (! $temporary) { |
if (! $temporary) { |
| header('HTTP/1.1 301 Moved Permanently'); |
switch($status_code) { |
| |
case 303: |
| |
header('HTTP/1.1 303 See Other'); |
| |
break; |
| |
case 302: |
| |
header('HTTP/1.1 302 Found'); |
| |
break; |
| |
case 301: |
| |
default: |
| |
header('HTTP/1.1 301 Moved Permanently'); |
| |
break; |
| |
} |
| } |
} |
| exit; |
exit; |
| } /* }}} */ |
} /* }}} */ |
|
|
| # }}} |
# }}} |
| |
|
| /** |
/** |
| |
* Insert element into array on specific index. |
| |
* |
| |
* @param array $arr input array |
| |
* @param int $index position in array |
| |
* @param mix $element inserted element |
| |
* @return array output array |
| |
*/ |
| |
static function array_insert($arr, $index, $element) |
| |
{ |
| |
if (!is_array($arr)) { |
| |
return false; |
| |
} |
| |
$index = intval($index); |
| |
if ($index > count($arr)-1) { |
| |
array_push($arr, $element); |
| |
return $arr; |
| |
} |
| |
$before = array_splice($arr, 0, $index); |
| |
array_push($before, $element); |
| |
return array_merge($before, $arr); |
| |
} |
| |
|
| |
/** |
| * Returns english grammar related number. |
* Returns english grammar related number. |
| * |
* |
| * @param int $number intput number |
* @param int $number intput number |