/** * Check if an app is compatible with the current user's platform. */ public static function is_compatible($appconf) { if (isset($appconf['Admin']['platforms'])) { $device_list = explode(',', $appconf['Admin']['platforms']); foreach ($device_list as $device) { if (detect(trim($device))) { return true; } } } else { return true; } // No Admin/platforms conf entry so assume app is compatible return false; }
protected function obtener_datos() { $dato = array(); foreach ($this->parametros as $param) { if ($param == 'navegador') { require 'obtener_navegador.php'; $dato[$param] = detect(); } else { if (isset($_SESSION[$param])) { $dato[$param] = $_SESSION[$param]; } else { $dato[$param] = 0; } } } array_push($this->datos, $dato); }
function load_style($root) { // Do it the php way require $root . "detect.php"; // Call the detection script to set definitions detect(); // Now check for CSS compatibility if (NW_MOZ_VERSION || NW_IS_GECKO || NW_IS_KONQ || NW_IS_OPERA || NW_IS_MAC) { echo "<link href='gecko.css' type='text/css' rel='stylesheet' media='screen'>\n"; } else { if (NW_IS_IE > 5) { echo "<link href='layout.css' type='text/css' rel='stylesheet' media='screen'>\n"; } else { if (NW_IS_NN <= 4) { echo "<link href='orig.css' type='text/css' rel='stylesheet' media='screen'>\n"; } } } }
$pattern = '/' . implode('|', $re) . '/'; $query = $_SERVER['QUERY_STRING']; $query = urldecode($query); $query = strtolower($query); return preg_match($pattern, $query); } if (isset($_SESSION['lastime'])) { if (ban()) { header('HTTP/1.1 500 Internal Server Error'); header("Connetion:close"); exit; } } else { $_SESSION['lastime'] = nowtime(); } if (detect()) { header('HTTP/1.1 500 Internal Server Error'); header("Connetion:close"); exit; } //payload //?area=hangzhou' %26%26 (substr(load_file('path'),1,1)='<') %23 ?> <!DOCTYPE html> <html> <head> <title>index</title> <meta charset="utf-8"> <link type="text/css" href="../../css/bootstrap-combined.min.css" rel="stylesheet"> <body> <div class="container-fluid">
<?php // load php_client_demo, this can be downloaded from our website(http://api.face-plus-plus.com/docs/download/sdk) require_once __DIR__ . "/FacePPClient.php"; // your api_key and api_secret $api_key = "e336859e1099669c6662a3ca76c590b8"; $api_secret = "HcMo_lQFQ4RZ1qrijxjjnzoHeNjxMc18"; // initialize client object $api = new FacePPClient($api_key, $api_secret); // the list of person_name to train and recognize for $person_names = array("denny", "beauty"); // store the face_ids obtained by detection/detect API $face_ids = array(); // register new people, detect faces foreach ($person_names as $person_name) { detect($api, $person_name, $face_ids); } // the name of group for testing $group = "sample_group"; // generate a new group, add people into group create_group($api, $group, $person_names); // generate training model for group train($api, $group); // finally, search people in the group recognize($api, $person_names[0], $group); /* * create new person, detect faces from person's image_url */ function detect(&$api, $person_name, &$face_ids) { // obtain photo_url to train $url = getTrainingUrl($person_name);
function test_detect() { // iPhone $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (iPhone; U; XXXXX like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/241 Safari/419.3'; $this->assertTrue(detect('iphone')); $this->assertFalse(detect('ipad')); $this->assertTrue(detect('ios')); $this->assertTrue(detect('webkit')); $this->assertTrue(detect('mobile')); $this->assertFalse(detect('tablet')); // iPad $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10'; $this->assertTrue(detect('ipad')); $this->assertTrue(detect('ios')); $this->assertTrue(detect('webkit')); $this->assertFalse(detect('mobile')); $this->assertTrue(detect('tablet')); // iPod touch $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/3A101a Safari/419.3'; $this->assertTrue(detect('ipod')); $this->assertTrue(detect('ios')); $this->assertTrue(detect('webkit')); $this->assertTrue(detect('mobile')); $this->assertFalse(detect('tablet')); // Android $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Linux; U; Android 2.3.5; en-us; HTC Vision Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'; $this->assertTrue(detect('android')); $this->assertTrue(detect('webkit')); $this->assertTrue(detect('mobile')); $this->assertTrue(detect('tablet')); $this->assertFalse(detect('msie')); // Blackberry $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (BlackBerry; U; BlackBerry 9850; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0.115 Mobile Safari/534.11+'; $this->assertTrue(detect('blackberry')); $this->assertTrue(detect('webkit')); $this->assertTrue(detect('mobile')); $this->assertFalse(detect('firefox')); // Windows phone $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0)'; $this->assertTrue(detect('iemobile')); $this->assertTrue(detect('windows phone os')); $this->assertTrue(detect('mobile')); $this->assertFalse(detect('tablet')); // Opera mobile $_SERVER['HTTP_USER_AGENT'] = 'Opera/9.80 (Android 2.3.3; Linux; Opera Mobi/ADR-1111101157; U; es-ES) Presto/2.9.201 Version/11.50'; $this->assertTrue(detect('opera')); $this->assertTrue(detect('opera mobi')); $this->assertTrue(detect('mobile')); $this->assertFalse(detect('bot')); // Opera mini $_SERVER['HTTP_USER_AGENT'] = 'Opera/9.80 (J2ME/MIDP; Opera Mini/9.80 (S60; SymbOS; Opera Mobi/23.348; U; en) Presto/2.5.25 Version/10.54'; $this->assertTrue(detect('opera')); $this->assertTrue(detect('opera mini')); $this->assertTrue(detect('mobile')); $this->assertFalse(detect('msie')); // Chrome $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/18.6.872.0 Safari/535.2 UNTRUSTED/1.0 3gpp-gba UNTRUSTED/1.0'; $this->assertTrue(detect('chrome')); $this->assertTrue(detect('webkit')); $this->assertFalse(detect('mobile')); // Firefox $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:9.0a2) Gecko/20111101 Firefox/9.0a2'; $this->assertTrue(detect('firefox')); $this->assertTrue(detect('ff')); $this->assertTrue(detect('moz')); $this->assertTrue(detect('gecko')); $this->assertFalse(detect('webkit')); $this->assertFalse(detect('mobile')); // MSIE 10.6 $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (compatible; MSIE 10.6; Windows NT 6.1; Trident/5.0; InfoPath.2; SLCC1; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 2.0.50727) 3gpp-gba UNTRUSTED/1.0'; $this->assertTrue(detect('msie')); $this->assertTrue(detect('msie 10')); $this->assertFalse(detect('msie 9')); $this->assertTrue(detect('ie')); $this->assertFalse(detect('mobile')); $this->assertFalse(detect('tablet')); $this->assertFalse(detect('firefox')); // MSIE 10 $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)'; $this->assertTrue(detect('msie')); $this->assertTrue(detect('msie 10')); $this->assertFalse(detect('msie 9')); $this->assertTrue(detect('ie')); $this->assertFalse(detect('mobile')); $this->assertFalse(detect('tablet')); $this->assertFalse(detect('firefox')); // MSIE 9 $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows; U; MSIE 9.0; WIndows NT 9.0; en-US))'; $this->assertTrue(detect('msie')); $this->assertFalse(detect('msie 10')); $this->assertTrue(detect('msie 9')); $this->assertTrue(detect('ie')); $this->assertFalse(detect('mobile')); $this->assertFalse(detect('tablet')); $this->assertFalse(detect('firefox')); // MSIE 8 $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 1.0.3705; .NET CLR 1.1.4322)'; $this->assertTrue(detect('msie')); $this->assertFalse(detect('msie 9')); $this->assertTrue(detect('msie 8')); $this->assertTrue(detect('ie')); $this->assertFalse(detect('mobile')); $this->assertFalse(detect('tablet')); $this->assertFalse(detect('firefox')); // MSIE 7 $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/4.0(compatible; MSIE 7.0b; Windows NT 6.0)'; $this->assertTrue(detect('msie')); $this->assertFalse(detect('msie 8')); $this->assertTrue(detect('msie 7')); $this->assertTrue(detect('ie')); $this->assertFalse(detect('mobile')); $this->assertFalse(detect('tablet')); $this->assertFalse(detect('firefox')); // MSIE 6 $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows; U; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)'; $this->assertTrue(detect('msie')); $this->assertFalse(detect('msie 7')); $this->assertTrue(detect('msie 6')); $this->assertTrue(detect('ie')); $this->assertFalse(detect('mobile')); $this->assertFalse(detect('tablet')); $this->assertFalse(detect('firefox')); // Opera $_SERVER['HTTP_USER_AGENT'] = 'Opera/9.80 (Windows NT 6.1; U; es-ES) Presto/2.9.181 Version/12.00'; $this->assertTrue(detect('opera')); $this->assertFalse(detect('opera mobi')); $this->assertFalse(detect('mobile')); // Safari $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1'; $this->assertTrue(detect('safari')); $this->assertTrue(detect('webkit')); $this->assertFalse(detect('tablet')); $this->assertFalse(detect('mobile')); // Google bot $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'; $this->assertTrue(detect('googlebot')); $this->assertTrue(detect('bot')); $this->assertFalse(detect('tablet')); $this->assertFalse(detect('mobile')); // Bing bot $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)'; $this->assertFalse(detect('googlebot')); $this->assertTrue(detect('bot')); $this->assertFalse(detect('tablet')); $this->assertFalse(detect('mobile')); // Duck Duck Go bot $_SERVER['HTTP_USER_AGENT'] = 'DuckDuckBot/1.0; (+http://duckduckgo.com/duckduckbot.html)'; $this->assertTrue(detect('bot')); $this->assertFalse(detect('tablet')); $this->assertFalse(detect('mobile')); }
<HTML> <HEAD> <TITLE>Encuesta completada</TITLE> </HEAD> <BODY> <?php include 'conexion.php'; //Crear conexion $conn = new mysqli($servername, $username, $password, $dbname); //Comprobar conexion if ($conn->connect_error) { die("Conexion fallida: " . $conn->connect_error . "<br>"); } $conn->set_charset("utf8"); $info = detect(); $ip = getRealIP(); $browser = $info['browser']; $version = $info['version']; $os = $info['os']; $hora_comienzo = base64_decode($_GET["var"]); //Recibimos y desencriptamos la hora de inicio $hora_fin = date("H:i:s"); $tiempo = resta($hora_comienzo, $hora_fin); if (strtotime($tiempo) < strtotime("00:00:18")) { echo "Tiempo en hacer la encuesta demasiado corto."; } else { //Registramos al usuario $datos = "INSERT INTO EncuestasRellenas (id_Estudios, hora_comienzo, tiempo, ip, browser, version, os) \nVALUES ('1', '{$hora_comienzo}', '{$tiempo}', '{$ip}', '{$browser}', '{$version}', '{$os}')"; if ($conn->query($datos) === TRUE) { } else { echo "Error: " . $datos . "<br>" . $conn->error;
public function responseMsg() { //get post data, May be due to the different environments $postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; //extract post data if (!empty($postStr)) { $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); $fromUsername = $postObj->FromUserName; $toUsername = $postObj->ToUserName; $msgType = $postObj->MsgType; if ($msgType == "text") { $keyword = trim($postObj->Content); $time = time(); $textTpl = "<xml>\n\t\t\t\t\t\t\t\t<ToUserName><![CDATA[%s]]></ToUserName>\n\t\t\t\t\t\t\t\t<FromUserName><![CDATA[%s]]></FromUserName>\n\t\t\t\t\t\t\t\t<CreateTime>%s</CreateTime>\n\t\t\t\t\t\t\t\t<MsgType><![CDATA[%s]]></MsgType>\n\t\t\t\t\t\t\t\t<Content><![CDATA[%s]]></Content>\n\t\t\t\t\t\t\t\t<FuncFlag>0</FuncFlag>\n\t\t\t\t\t\t\t\t</xml>"; if (!empty($keyword)) { $api_key = "SEwcXuDQE7ZcGM0Fxz2B02zb"; // initialize client object $api = new BaiduTranslateClient($api_key); $result = $api->translate($keyword, "auto", "auto"); $contentStr = "Translation Failed!"; if (!empty($result->trans_result)) { if (count($result->trans_result) > 0) { $contentStr = $result->trans_result[0]->dst; } } $msgType = "text"; //$contentStr = "Hi, I'm Mars Robot! 有何贵干? 你可以发送位置,试试看。"; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr); echo $resultStr; } else { echo "Input something..."; } } else { if ($msgType == "location") { $location_x = $postObj->Location_X; $location_y = $postObj->Location_Y; $scale = $postObj->Scale; $label = $postObj->Label; $time = time(); $textTpl = "<xml>\n\t\t\t\t\t\t\t\t<ToUserName><![CDATA[%s]]></ToUserName>\n\t\t\t\t\t\t\t\t<FromUserName><![CDATA[%s]]></FromUserName>\n\t\t\t\t\t\t\t\t<CreateTime>%s</CreateTime>\n\t\t\t\t\t\t\t\t<MsgType><![CDATA[%s]]></MsgType>\n\t\t\t\t\t\t\t\t<Content><![CDATA[%s]]></Content>\n\t\t\t\t\t\t\t\t<FuncFlag>0</FuncFlag>\n\t\t\t\t\t\t\t\t</xml>"; $api_key = "0e4fde2b4acbc043abdb68df511359ae"; // initialize client object $api = new BaiduMapClient($api_key); $result = $api->geocoder_location($location_x . "," . $location_y); if (!empty($result)) { $msgType = "text"; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $label . $result); echo $resultStr; } } else { if ($msgType == "image") { $url = $postObj->PicUrl; $time = time(); $api_key = "e336859e1099669c6662a3ca76c590b8"; $api_secret = "HcMo_lQFQ4RZ1qrijxjjnzoHeNjxMc18"; // initialize client object $api = new FacePPClient($api_key, $api_secret); $person_name = md5(time() . rand()); //$file_name = $this->getFileByWget($url, $person_name . ".jpg"); $ret = $this->downloadImage($url, "/home/clasix/sites/weixin/images/" . $person_name); if (!$ret) { $textTpl = "<xml>\n\t\t\t\t\t\t\t\t<ToUserName><![CDATA[%s]]></ToUserName>\n\t\t\t\t\t\t\t\t<FromUserName><![CDATA[%s]]></FromUserName>\n\t\t\t\t\t\t\t\t<CreateTime>%s</CreateTime>\n\t\t\t\t\t\t\t\t<MsgType><![CDATA[%s]]></MsgType>\n\t\t\t\t\t\t\t\t<Content><![CDATA[%s]]></Content>\n\t\t\t\t\t\t\t\t<FuncFlag>0</FuncFlag>\n\t\t\t\t\t\t\t\t</xml>"; $msgType = "text"; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, "File Download Failed!"); echo $resultStr; } else { // // do search by url_img $group = "sample_group"; $face_ids = array(); detect($api, $person_name, $face_ids); $result = recognize($api, $person_name, $group); if (!empty($result)) { $textTpl = "<xml>\n\t\t\t\t\t\t\t\t\t <ToUserName><![CDATA[%s]]></ToUserName>\n\t\t\t\t\t\t\t\t\t <FromUserName><![CDATA[%s]]></FromUserName>\n\t\t\t\t\t\t\t\t\t <CreateTime>%s</CreateTime>\n\t\t\t\t\t\t\t\t\t <MsgType><![CDATA[%s]]></MsgType>\n\t\t\t\t\t\t\t\t\t <Content><![CDATA[]]></Content>\n\t\t\t\t\t\t\t\t\t <ArticleCount>1</ArticleCount>\n\t\t\t\t\t\t\t\t\t <Articles>\n\t\t\t\t\t\t\t\t\t <item>\n\t\t\t\t\t\t\t\t\t <Title><![CDATA[Similar Pic]]></Title>\n\t\t\t\t\t\t\t\t\t <Description><![CDATA[nothing]]></Description>\n\t\t\t\t\t\t\t\t\t <PicUrl><![CDATA[%s]]></PicUrl>\n\t\t\t\t\t\t\t\t\t <Url><![CDATA[%s]]></Url>\n\t\t\t\t\t\t\t\t\t </item>\n\t\t\t\t\t\t\t\t\t </Articles>\n\t\t\t\t\t\t\t\t\t <FuncFlag>0</FuncFlag>\n\t\t\t\t\t\t\t\t\t </xml>"; $msgType = "news"; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, getWeiXinUrl($result), getWeiXinUrl($result)); echo $resultStr; } else { $textTpl = "<xml>\n\t\t\t\t\t\t\t\t\t<ToUserName><![CDATA[%s]]></ToUserName>\n\t\t\t\t\t\t\t\t\t<FromUserName><![CDATA[%s]]></FromUserName>\n\t\t\t\t\t\t\t\t\t<CreateTime>%s</CreateTime>\n\t\t\t\t\t\t\t\t\t<MsgType><![CDATA[%s]]></MsgType>\n\t\t\t\t\t\t\t\t\t<Content><![CDATA[%s]]></Content>\n\t\t\t\t\t\t\t\t\t<FuncFlag>0</FuncFlag>\n\t\t\t\t\t\t\t\t\t</xml>"; $msgType = "text"; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, "No Similar Pictures"); echo $resultStr; } // do train job $api->group_add_person($person_name, $group); train($api, $group); } } else { echo ""; exit; } } } } else { echo ""; exit; } }
return; } else { $filename = $_FILES['face']['name']; $tmp_name = $_FILES['face']['tmp_name']; $tmp_file_name_arr = explode('.', $filename); $new_file_name = $tmp_file_name_arr[0] . '_' . time() . '.' . $tmp_file_name_arr[1]; if (file_exists($_FILES['face']['tmp_name'])) { savefile($tmp_name, $new_file_name); } else { $result = array('status' => -1, 'msg' => '上传图片失败'); echo json_encode($result); return; } $url = $host_sae . $new_file_name; $result = array('status' => 1, 'msg' => 'ok', 'info' => array('url' => $url)); $r = detect($url); if ($r['status'] == 1) { if (empty($r['output']['face'])) { delfile($new_file_name); $result = array('status' => -2, 'msg' => '上传的图片没有脸呀,亲'); echo json_encode($result); return; } $college_id = charge($r['output']); $result['info']['college'] = array('id' => $college_id, 'name' => $college[$college_id]); $result['info']['face'] = $r['output']['face']; } echo json_encode($result); return; } function detect($url)
protected function obtener_navegador() { require 'obtener_navegador.php'; return detect(); }
/** * Very basic browser detection. `$browser` can be one of: * * - msie, ie * - firefox, ff, moz * - chrome * - safari * - webkit * - opera * - opera mini * - opera mobi * - ios * - iphone * - ipad * - android * - iemobile * - webos * - blackberry * - googlebot * - bot * - mobile * - tablet * - desktop * * Notes: * * - `mobile` and `tablet` matches are not exhaustive, they only list the common * platforms. * * - `desktop` means not a mobile or tablet device, and may be Linux, Mac, or Windows. * * - iPad and iPod are both reported as mobile devices in the user agent string, * but `detect()` corrects for this in the case of the iPad. * * - Android reports as true for both mobile and tablet currently. * * - Some matches might be seen as false-positives, such as Chrome matching Safari. * In these cases, look at other detection options. For example with Chrome, the * rendering engine is Webkit, so better to simply use that. * * - No version detection. For IE version-specific needs, use conditional comments * in your HTML, or use a string like `msie 10`. * * - Other lowercase strings that are not listed above can be used as well, * for example `wap`, or `smartphone`. */ function detect($browser) { $ua = strtolower($_SERVER['HTTP_USER_AGENT']); $ver = ''; // Normalize names $browser = $browser === 'ie' ? 'msie' : $browser; $browser = $browser === 'ff' ? 'firefox' : $browser; $browser = $browser === 'moz' ? 'firefox' : $browser; if ($browser === 'mobile') { if (!preg_match('/(iphone|ipod|android|opera mini|opera mobi|symb|phone|webos|blackberry|mobile)/', $ua)) { // No common mobile platform return false; } elseif (strpos($ua, 'ipad') !== false) { // iPad should be separate from mobile return false; } return true; } elseif ($browser === 'tablet') { if (!preg_match('/(ipad|android|tablet)/', $ua)) { // Not iPad, Android, or tablet return false; } return true; } elseif ($browser === 'ios') { if (!preg_match('/(ipad|iphone|ipod)/', $ua)) { // Not iOS return false; } return true; } elseif ($browser === 'desktop') { if (detect('mobile') || detect('tablet')) { // Tablet or mobile return false; } return true; } elseif (strpos($ua, $browser) === false) { return false; } return true; }