die; } if (isset($key)) { $key .= ",`" . $v . "`"; $value .= ",'" . mysql_real_escape_string($_POST[$v]) . "'"; } else { $key = "`" . $v . "`"; $value = "'" . mysql_real_escape_string($_POST[$v]) . "'"; } } $mysql = new Mysql(); //连接数据库 $userName = $_POST['userName']; $result = $mysql->select("*", 'user', '`username`', "'{$userName}'"); if (!$result) { $mysql->replace("user", "{$key}", "{$value}"); $userId = mysql_insert_id(); $mysql->close(); } else { $res = ['ok' => 0, 'error' => 'username existed']; echo json_encode($res); die; } $myMemcache = new MyMemcache(); $expireTime = 7 * 24 * 3600; $token = md5(uniqid(rand(), TRUE)); $myMemcache->set("u" . $userId, $token, $expireTime); $myMemcache->set($token, $userId, $expireTime); $myMemcache->close(); $user = [userId => $userId, token => $token, expireTime => $expireTime]; $res = [ok => 1, data => $user];
$_GET['like'] = $myMemcache->get("like" . $_GET['id']) ? $myMemcache->get("like" . $_GET['id']) + 1 : 1; $FootList = array('url', 'title', 'id', 'like'); } else { $_GET['like'] = 1; $FootList = array('url', 'title'); } foreach ($FootList as $k => $v) { if (isset($key)) { $key .= ",`" . $v . "`"; $value .= ",'" . mysql_real_escape_string($_GET[$v]) . "'"; } else { $key = "`" . $v . "`"; $value = "'" . mysql_real_escape_string($_GET[$v]) . "'"; } } $mysql->replace("foot", "{$key}", "{$value}"); //插入数据 unset($value); unset($key); } $_GET['footId'] = mysql_insert_id(); //echo $_GET['footId']; $myMemcache->set("like" . $_GET['footId'], $_GET['like']); if (isset($_GET['url'])) { $myMemcache->set($_GET['url'], $_GET['footId']); } $_GET['timestamp'] = time(); $footprintId = $myMemcache->get($_GET['userId'] . "foot:" . $_GET['footId']); $FootPrintList = array('userId', 'footId', 'initiative', 'time', 'timestamp'); foreach ($FootPrintList as $k => $v) { if (isset($key)) {
//打印出所有的 错误信息 ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); include "../Visitor.php"; $userId = getUserId(); $mysql = new Mysql(); //$regular=new Regular(null); //$regular->host="http://www.google.com/"; //$regular->threshold=100; //$regulars[]=$regular; // //$regular=new Regular(null); //$regular->host="http://www.jd.com/"; //$regular->threshold=10000; //$regulars[]=$regular; //var_dump($_POST['data']); $regulars = json_decode($_POST['data']); $myMemcache = new MyMemcache(); foreach ($regulars as $item) { $key = $item->threshold . "_" . $item->host; if ($myMemcache->get($key)) { $id = $myMemcache->get($key); } else { $mysql->insert("regular", "`host`,`threshold`", "'{$item->host}','{$item->threshold}'"); $id = mysql_insert_id(); $myMemcache->set($key, $id); } $time = time(); $mysql->replace("user_regular", "`user_id`,`regular_id`,`time`", "'{$userId}','{$id}','{$time}'"); } $data = json_encode($regulars); echo $data;