forked from binjospookie/--shots
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
33 lines (30 loc) · 855 Bytes
/
Copy pathfunctions.php
File metadata and controls
33 lines (30 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
/**
* Установить HTTP код результата
* @param string $code Строка кода (напр., '404 Not Found')
*/
function set_http_code( $code )
{
$sapi_name = php_sapi_name();
if ( $sapi_name == 'cgi' || $sapi_name == 'cgi-fcgi' )
{
header( 'Status: ' . $code );
}
else
{
header( $_SERVER['SERVER_PROTOCOL'] . ' ' . $code );
}
}
/**
* Получить дату в формате SQL из частей год, месяц, день
* @param string $year
* @param string $month
* @param string $day
* @return string
*/
function sql_date_from_parts( $year, $month, $day )
{
return str_pad( intval( $year ), 4, '0', STR_PAD_LEFT ) . '-'
. str_pad( intval( $month ), 2, '0', STR_PAD_LEFT ) . '-'
. str_pad( intval( $day ), 2, '0', STR_PAD_LEFT );
}