class Viber
{
private $url_api = "https://chatapi.viber.com/pa/";
private $token = "";
public function message_post
(
$from, // ID администратора Public Account.
array $sender, // Данные отправителя.
$text // Текст.
)
{
$data['from'] = $from;
$data['sender'] = $sender;
$data['type'] = 'text';
$data['text'] = $text;
return $this->call_api('post', $data);
}
private function call_api($method, $data)
{
$url = $this->url_api.$method;
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\nX-Viber-Auth-Token: ".$this->token."\r\n",
'method' => 'POST',
'content' => json_encode($data)
)
);
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
return json_decode($response);
}
}
$Viber = new Viber();
$Viber->message_post(
'01234567890A=',
[
'name' => 'Admin', // Имя отправителя. Максимум символов 28.
'avatar' => 'http://avatar.example.com' // Ссылка на аватарку. Максимальный размер 100кб.
],
'Test'
);
$arr = array (
1 => '{"id":1,"company_name":null,"v":"1232","description":"dfg","name":"ghdg","money":"567","Preview_image":"123"}',
2 => '{"id":2,"company_name":null,"v":"1232","description":"dfg","name":"ghdg","money":"567","Preview_image":"123"}',
3 => '{"id":3,"company_name":null,"v":"1232","description":"dfg","name":"ghdg","money":"12","Preview_image":"123"}');
foreach ($arr as $v) {
# code...
list($id, $company_name,$v) = explode(',', $v);
//echo $id,'<br>';
$company_name = explode(':',$company_name);
$v = explode(':',$v);
echo $company_name[1];
echo $v[1],'<br>';
echo "===<br>";
}
<div class="conteiner">
<div class="logo"></div>
<div class="header_info"></div>
<div class="phone"></div>
</div>
*{
margin: 0;
padding: 0;
}
.conteiner{
width: 960px;
height: 200px;
margin: 0 auto;
background:#ccc;
}
.logo,.header_info,.phone{
float: left;
}
.logo{
width: 33.333333%;
height: 50px;
background: yellow;
}
.header_info{
width: 33.333333%;
height: 50px;
background: green;
}
.phone{
width: 33.333333%;
height: 50px;
background: blue;
}
@media (max-width:800px){
.logo{
width: 100%;
float: none;
}
.header_info,.phone{
width: 50%;
float: left;
}
}
const DEG_TO_RAD = Math.PI / 180;
const RAD_TO_DEG = 180 / Math.PI;
const point = ( x = 0, y = 0 ) => ({ x, y });
const length = ( { x, y } ) => Math.sqrt( x * x + y * y );
const normalize = ( vector ) => {
let vectorLength = length( vector );
let { x, y } = vector;
return point( x / vectorLength, y / vectorLength );
};
const subtract = ( a, b ) => ({ x: a.x - b.x, y: a.y - b.y });
const DIRECTIONS = {
TOP: "top",
RIGHT: "right",
BOTTOM: "bottom",
LEFT: "left"
};
const defaultBorder = `3px solid black`;
const getBorder = side => ({
borderTop: `${ side === DIRECTIONS.TOP ? defaultBorder : '' }`,
borderRight: `${ side === DIRECTIONS.RIGHT ? defaultBorder : '' }`,
borderBottom: `${ side === DIRECTIONS.BOTTOM ? defaultBorder : '' }`,
borderLeft: `${ side === DIRECTIONS.LEFT ? defaultBorder : '' }`,
})
const actionMap = {
[ DIRECTIONS.TOP ]: element => Object.assign( element.style, getBorder( DIRECTIONS.TOP ) ),
[ DIRECTIONS.RIGHT ]: element => Object.assign( element.style, getBorder( DIRECTIONS.RIGHT ) ),
[ DIRECTIONS.BOTTOM ]: element => Object.assign( element.style, getBorder( DIRECTIONS.BOTTOM ) ),
[ DIRECTIONS.LEFT ]: element => Object.assign( element.style, getBorder( DIRECTIONS.LEFT ) ),
}
let rect = document.body.querySelector('.rect');
let rectangle = rect.getBoundingClientRect();
let center = point(
rectangle.width / 2 + rectangle.left,
rectangle.height / 2 + rectangle.top
);
document.addEventListener('mousemove', document_mouseMoveHandler);
function document_mouseMoveHandler( { clientX, clientY } ){
let mouse = point( clientX, clientY );
let mc = subtract( mouse, center );
let direction = normalize( mc );
let angle = Math.atan2( direction.y, direction.x ) * RAD_TO_DEG;
let type = getDirection( angle );
let action = actionMap[ type ];
action( rect );
}
function getDirection( angle ){
if( angle <= -45 && angle > -130 ){
return DIRECTIONS.TOP;
}else if( angle > -180 && angle <= -130 || angle <= 180 && angle > 130 ){
return DIRECTIONS.LEFT;
}else if( angle > 45 && angle <= 130 ){
return DIRECTIONS.BOTTOM;
}else if( angle <= 45 && angle > -45 ){
return DIRECTIONS.RIGHT;
}
}
/* css */
.rect {
width: 100px;
height: 100px;
background: tomato;
position: absolute;
top: 50%;
left: 50%;
transform: translate( -50%, -50% );
}
<div class="rect"></div>
<form id="form" action="" name="myForm" method="POST">
<input type="radio" name="price" value="100"><span>100</span>
<br>
<input type="radio" name="price" value="10000" ><span>10000</span>
<br>
<input type="radio" name="price" value="1000000" ><span>1000000</span>
<br>
<button>Кнопка 1</button>
</form>
<br>
<br>
<button form="form">Кнопка 2</button>
<a href="index.php?cat=1">
<a href="index.php?cat=2">
<a href="index.php?cat=3">
$id_cat = $_GET['cat']; // сюда попадет id категории предположим цыфра 3
// делаем запрос
// Вывести все из таблице videos где id = 3 ну и сортировка ORDER BY `id` DESC LIMIT 5
$sql = "SELECT * FROM `videos` WHERE id=$id_cat ORDER BY `id` DESC LIMIT 5";
$videos = mysqli_query($connection, $sql);