Files
Testing/include/analytics/videos/speedtest.php
sean 0e8a8b3028
Some checks are pending
deploy-testing / deploy (push) Waiting to run
Initial testing snapshot
2026-11-17 16:15:01 -05:00

71 lines
2.1 KiB
PHP

<?php header('Content-type: application/json; charset=utf-8');
if ( !defined('PATHTOINCLUDES') ) define('PATHTOINCLUDES', $_SERVER["DOCUMENT_ROOT"] . '/bebop/');
include(PATHTOINCLUDES."regular.php");
ini_set('display_errors','On');
if(!isset($_SESSION['connectionspeed'])){$_SESSION['connectionspeed']=0;}
if($_SESSION['connectionspeed']===0 || $_SESSION['connectionspeed']==="")
{
$cpseed="";
$html5="";
$devicetype="";
$ostype="";
$userid="";
if(isset($_GET['uid'])){$userid=$_GET['uid'];}
if(isset($_GET['html5video'])){$html5=$_GET['html5video'];}
if(isset($_GET['dt'])){$devicetype=$_GET['dt'];}
if(isset($_GET['ost'])){$ostype=$_GET['ost'];}
$kb=512;
flush();
$time = explode(" ",microtime());
$start = $time[0] + $time[1];
for($x=0;$x<$kb;$x++){
flush();
}
$time = explode(" ",microtime());
$finish = $time[0] + $time[1];
$deltat = $finish - $start;
$cspeed=round($kb / $deltat, 3);
$em="";
$sql="";
$mysqli = new mysqli("localhost", "db.bateworldcom", "sDIE8U8!5n*4%Ue_x.Pq", "bateworldcom");
if ($mysqli->connect_errno) {$em = $mysqli->connect_error;}
if($em==="")
{
$browser=$_SERVER['HTTP_USER_AGENT'] ;
$db_table="cockology_stats";
$sql = 'INSERT INTO `'.$db_table.'`(`connection_speed`, `html5video`, `devicetype`, `ostype`, `userid`, `thebrowser`, `datecreated`)'.' VALUES (?, ?, ?, ?, ?, ?, UTC_TIMESTAMP())';
if($query = $mysqli->prepare($sql))
{
$query->bind_param(
'dsssis',
$cspeed,
$html5,
$devicetype,
$ostype,
$userid,
$browser) ;
$query->execute();
$cockid = $mysqli->insert_id;
} else {
$em = $mysqli->errno . ' ' . $mysqli->error;
}
}
if ($mysqli->connect_errno) {$em = $mysqli->connect_error;}
else{$_SESSION['connectionspeed']=$cspeed;}
$arr = array ('connectionspeed'=> $cspeed, 'cset'=>"set", 'error_message' => $em);
echo json_encode($arr);
exit();
}
$arr = array ('connectionspeed'=> $_SESSION['connectionspeed'], 'cset'=>"not set", 'error_message' => "");
echo json_encode($arr);
exit();
?>