empty(trim($this->request->post['email']))
ob_implicit_flush();
if( ($sock = socket_create( AF_INET, SOCK_STREAM, SOL_TCP )) === false )
{
self::fault(self::ERROR_SCR, $sock, __LINE__);
exit();
}
socket_set_option($sock, SOL_SOCKET, SO_REUSEADDR, 1);
self::log("сервер: сокет создан\n");
if( socket_bind( $sock, $_SERVER['HTTP_HOST'], self::$port ) === false )
{
self::fault(self::ERROR_SBND, $sock, __LINE__);
exit();
}
self::log("сервер: сокет привязан\n");
if( socket_listen( $sock, 2 ) === false )
{
self::fault(self::ERROR_SLI, $sock, __LINE__);
exit();
}
self::log("сервер: сокет слушается\n");
session_write_close();
socket_set_nonblock($sock);
private
function getAcceptMsg($input)
{
preg_match("/Sec-WebSocket-Key: (.*);/uU", $input, $temp );
$key_acp = $temp[ 1 ];
$key_acp = base64_encode( sha1( $key_acp . "258EAFA5-E914-47DA-95CA-C5AB0DC85B11", true ) );
$msg = "HTTP/1.1 101 Swithing Protocols\r\n";
$msg .= "Upgrade: websocket\r\n";
$msg .= "Connection: Upgrade\r\n";
$msg .= "Sec-Websocket-Accept: {$key_acp}\r\n\r\n";
return $msg;
}
//отвечаем браузеру
$msg = $this->getAcceptMsg($input);
socket_write( $msgsock, $msg, strlen( $msg ) );
socket_set_nonblock($msgsock);
select * from (
SELECT u.firstname AS 'First' , u.lastname AS 'Last',
c.fullname AS 'Course',
cc.name AS 'Category',
gi.itemname AS 'Mark name',
ROUND (ggh.finalgrade) AS Grade,
ggh.timemodified
FROM prefix_course AS c
JOIN prefix_context AS ctx ON c.id = ctx.instanceid
JOIN prefix_role_assignments AS ra ON ra.contextid = ctx.id
JOIN prefix_user AS u ON u.id = ra.userid
JOIN prefix_grade_grades_history AS ggh ON ggh.userid = u.id
JOIN prefix_grade_items AS gi ON gi.id = ggh.itemid AND gi.courseid = c.id
JOIN prefix_course_categories AS cc ON cc.id = c.category
WHERE ggh.source LIKE '%attendance%' AND ggh.finalgrade<85 AND ggh.timemodified<=1420786524
) as t
where t.`timemodified` = max(t.`timemodified`)
GROUP BY t.`First`, t.`Last`, t.`Course`, t.`Category`, t.`Mark name`
foreach ($data as $item)
{
$insert = array();
if ($item['data_type'] === 'photoSignImage')
{
$insert['path'] = $item['post_data'];
}
elseif ($item['data_type'] === 'photo')
{
$insert['comment'] = $item['post_data'];
}
$insert['id'] = $item['post_id'];
db::insert_record('table', $insert);
}