function main() { if (!(($phone = @$_GET['phone']) && ($key = @$_GET['key']))) { echo 'invalid reference'; return 1; } if (!checkKey($key)) { echo 'invalid key'; return 2; } /** @var WP_User $user */ $user = getUserByPhone($phone); if (!$user) { echo 'no user found'; } $geocode = get_user_meta($user->ID, 'geocode', true); $ret = explode(',', $geocode); echo json_encode($ret); }
$conn = db_connect(); $conn->set_charset("utf8"); // 指定数据库字符编码 $querySQL = $baseSQL . "where phone = \"{$phoneNumber}\""; $result = $conn->query($querySQL); if (!$result) { throw new Exception('Search user failed.'); } $num_result = $result->num_rows; if (0 >= $num_result) { echo "查询数据失败, SQL:" . $querySQL; return $userArray; } elseif (1 < $num_result) { throw new Exception('Get more than one user with same user phone number!'); } $row_db = $result->fetch_assoc(); $userArray['total'] = 1; $userArray["row"][0] = convertDBRowToArray($row_db); $result->free(); $conn->close(); return json_encode($userArray); } switch ($filterType) { case "id": $resultJsonStr = getUserByID($userID); break; case "phone": $resultJsonStr = getUserByPhone($phoneNumber); break; } print "{$resultJsonStr}";
$message = trim(substr($message, strpos($message, ':') + 1)); $media = mediaURLForPhone($phone); foreach ($SYSTEM_ADMIN_PHONES as $adminPhone) { singleSMS($adminPhone, $phone . ' (' . $name . ')' . ":\n\n" . $message, $media); } } if (!isset($_REQUEST['MessageSid'])) { die; } $sms = $twilio->account->messages->get($_REQUEST['MessageSid']); if (!$sms || $sms->from == $sms->to) { die; } $phone = substr(trim($sms->from), -10); $message = trim($sms->body); if ($user = getUserByPhone($phone)) { $didStoreMedia = checkAndStoreMedia($phone, $sms, $user); if (startsWith(strtoupper($message), 'MSG:')) { proccessAdminMessage($phone, $message, $user['name']); return singleSMS($phone, SYSTEM_RESPONSE_ADMIN_SENT); } if ($user['waiting_name']) { if (strtoupper($message) == "WITHDRAW") { DB::delete('users', "user_id=%d", $user['user_id']); return singleSMS($phone, SYSTEM_RESPONSE_WITHDRAW); } $names = explode(" ", $message); if (count($names) < 2) { return singleSMS($phone, "Please enter a valid name."); } else { DB::update('users', array('name' => $message, 'waiting_name' => false), 'user_id=%d', $user['user_id']);