diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..f3bbedb --- /dev/null +++ b/COPYING @@ -0,0 +1,13 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + 14 rue de Plaisance, 75014 Paris, France + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. \ No newline at end of file diff --git a/README b/README new file mode 100644 index 0000000..abda7f4 --- /dev/null +++ b/README @@ -0,0 +1,25 @@ +1.0 - Initial relsese +1.1 - Remaked the Google Laitiude code + - minor changes to the index.php + - removed the shout form in check.php (the damm PHP Class does not work for shouting) + - Private check in works + - +1.2 - now can add venue + - fix POST error + - show checkin response + - add shout, but not work + - suppot twitter & facebook +1.3 - shout now work +1.4 - add login screen, and logout + - add 4sqr logo +1.5 - fixed Issue 6 + - login screen add latidude_code, not need conf/conf.php + - Now latidude_code with minus sign (some latidude_code of user no with minus sign) + +2.0 - update to 4sq API V2, using foursquare-async, https://github.com/jmathai/foursquare-async + - rewrite code + - support upload photo +2.1 - fix Issue 12 + - Search Venues: add favorites, trending,and nearby types + - Google Places Searches + diff --git a/THANKSTO b/THANKSTO new file mode 100644 index 0000000..0077e0a --- /dev/null +++ b/THANKSTO @@ -0,0 +1 @@ +Thanks to Lucky Strike and Coke developers \ No newline at end of file diff --git a/add.php b/add.php new file mode 100644 index 0000000..b914380 --- /dev/null +++ b/add.php @@ -0,0 +1,43 @@ + + + + + + +

+post("/venues/add", array( + 'name' => "{$name}", 'address' => "{$address}", 'crossStreet' => "{$crossstreet}", 'city'=>"{$city}", 'state'=>"{$state}", 'zip'=>"{$zip}", 'phone'=>"{$phone}", 'll' => "{$geolat},{$geolong}" + )); +?> +
+Add new venue , OK!
+"; +$id=$venues->response->venue->id; +echo "Check in!
" ; +?> +
+Power by 4sqr. +
+ + diff --git a/check.php b/check.php new file mode 100644 index 0000000..89b8416 --- /dev/null +++ b/check.php @@ -0,0 +1,91 @@ + + + + + + + +

+"; + echo "
"; + echo"Add venue:
"; + echo"name:
"; + echo "address:
"; + echo "crossstreet:
"; + echo "city:
"; + echo "state:
"; + echo "zip:
"; + echo "phone:
"; + echo ""; + echo ""; + echo ""; + } + else { + $name=$placedetails["result"]["name"]; + $address=$placedetails["result"]["formatted_address"]; + if ($placedetails["result"]["address_components"] !=Null) { + foreach ($placedetails["result"]["address_components"] as $address_components) { + if ($address_components["types"][0]=="postal_code"){ + $zip=$address_components["long_name"]; + } + } + } + $phone=$placedetails["result"]["formatted_phone_number"]; + echo "
"; + echo ""; + echo"Add venue:
"; + echo"name:
"; + echo "address:
"; + echo "crossstreet:
"; + echo "city:
"; + echo "state:
"; + echo "zip:
"; + echo "phone:
"; + echo ""; + echo ""; + echo ""; + } + } + + +else { + $id = $_GET['id']; + $name = $_GET['name']; + $add = $_GET['add']; + $city = $_GET['city']; + $state = $_GET['state']; + echo "
"; + echo "Check in @ $name
"; + $array = array($add,$city,$state); + + $adds = implode(", ", $array); + + echo "$adds
"; + echo ""; + + echo ""; + echo ""; + echo ""; + echo ""; + echo "shout:
"; + echo "private:
"; + echo "twitter:
"; + echo "Facebook:
"; + echo "Photo:
"; + echo ""; + } +?> +
+Power by 4sqr. +
+ + diff --git a/checkin.php b/checkin.php new file mode 100644 index 0000000..504a710 --- /dev/null +++ b/checkin.php @@ -0,0 +1,106 @@ + + + + + + +

+post('/checkins/add',array( + 'venueId' => "{$id}", 'venue' => "{$name}", 'shout'=>"{$shout}", 'broadcast' => "{$privat}", 'll' => "{$geolat},{$geolong}" + )); + +if ($_FILES['photo']['name'] !=NULL){ + + if (($_POST['twitter']== 1) && ($_POST['facebook']== 0)){ + $privat = 'twitter'; + } + elseif (($_POST['twitter']== 0) && ($_POST['facebook']== 1)) { + $privat = 'facebook'; + } + elseif (($_POST['twitter']== 1) && ($_POST['facebook']== 1)) { + $privat = 'twitter,facebook'; + } + else { + $privat = ''; + } + $postVars = array(); + $postVars['checkinId'] = $checkin->response->checkin->id; + $postVars['ll'] = "{$geolat},{$geolong}"; + $postVars['broadcast'] = "{$privat}"; + $postVars['photo'] = '@'.$_FILES['photo']['tmp_name']; + + $pcheckin = $fsObjUnAuth->post('/photos/add', $postVars, $up=1); +} +?> +
+ +response->checkin->venue ->location->address; + +$notification=$checkin ->notifications; +foreach ($notification as $notifications){ + if ($notifications -> type == "message"){ + $message = $notifications->item->message; + echo "$message
"; + echo "$add
"; + if ($shout != NULL){ + echo "$shout
"; + } + } + if ($notifications -> type == "mayorship"){ + $mayor = $notifications->item->message; + echo "$mayor
"; + } + + if ($notifications -> type == "score"){ + $score = $notifications->item->scores; + if ($score != NULL){ + foreach ($score as $s){ + $points = $s->points; + $smessage = $s->message; + + echo "$smessage (+$points) pts
"; + } + } + $total = $notifications->item->total; + echo "Total: $total pts
"; + } +} +if ($_FILES['photo']['name'] !=NULL){ + $myphoto=$pcheckin->response->photo->sizes->items[2]->url; + echo "Photo upload done!
"; + echo ""; +} +?> +
+Power by 4sqr. +
+ + diff --git a/config.php b/config.php new file mode 100644 index 0000000..5662f08 --- /dev/null +++ b/config.php @@ -0,0 +1,8 @@ + diff --git a/index.php b/index.php new file mode 100644 index 0000000..da24a8f --- /dev/null +++ b/index.php @@ -0,0 +1,88 @@ + + + + + + + +

+getAuthorizeUrl($redirectUri); +?> + + getAccessToken($_GET['code'], $redirectUri); + setcookie('access_token', $token->access_token, time()+(100*24*3600)); + $_COOKIE['access_token'] = $token->access_token; + } ?> + setAccessToken($_COOKIE['access_token']); + $venues = $fsObjUnAuth->get('/venues/search', array('ll' => "{$latitude},{$longitude}", 'limit' => 50)); + foreach ($venues->response->groups as $groups) { + if ($groups->type =='favorites'){ + echo $groups->name.'
'; + foreach ($groups->items as $venue) { + $name = $venue->name; + $id = $venue->id; + $dist = $venue->location->distance; + $add = $venue->location->address; + $city = $venue->location->city; + $state = $venue->location->state; + echo "$name - $dist m
" ; + } + } + elseif ($groups->type =='trending'){ + echo $groups->name.'
'; + foreach ($groups->items as $venue) { + $name = $venue->name; + $id = $venue->id; + $dist = $venue->location->distance; + $add = $venue->location->address; + $city = $venue->location->city; + $state = $venue->location->state; + echo "$name - $dist m
" ; + } + } + elseif ($groups->type =='nearby') { + echo $groups->name.'
'; + foreach ($groups->items as $venue) { + $name = $venue->name; + $id = $venue->id; + $dist = $venue->location->distance; + $add = $venue->location->address; + $city = $venue->location->city; + $state = $venue->location->state; + echo "$name - $dist m
" ; + } + } + else { + foreach ($groups->items as $venue) { + $name = $venue->name; + $id = $venue->id; + $dist = $venue->location->distance; + $add = $venue->location->address; + $city = $venue->location->city; + $state = $venue->location->state; + echo "$name - $dist m
" ; + } + } + } + echo "
Place Searches
"; + echo "Add venue
"; + echo "I at here!
"; + echo "Logout
"; + } ?> +
+Power by 4sqr. +
+ + diff --git a/kernel/.svn/all-wcprops b/kernel/.svn/all-wcprops new file mode 100644 index 0000000..5ef6682 --- /dev/null +++ b/kernel/.svn/all-wcprops @@ -0,0 +1,41 @@ +K 25 +svn:wc:ra_dav:version-url +V 29 +/svn/!svn/ver/30/trunk/kernel +END +EpiFoursquare.php +K 25 +svn:wc:ra_dav:version-url +V 47 +/svn/!svn/ver/33/trunk/kernel/EpiFoursquare.php +END +latitude.php +K 25 +svn:wc:ra_dav:version-url +V 42 +/svn/!svn/ver/31/trunk/kernel/latitude.php +END +LICENSE +K 25 +svn:wc:ra_dav:version-url +V 37 +/svn/!svn/ver/33/trunk/kernel/LICENSE +END +EpiCurl.php +K 25 +svn:wc:ra_dav:version-url +V 41 +/svn/!svn/ver/33/trunk/kernel/EpiCurl.php +END +EpiSequence.php +K 25 +svn:wc:ra_dav:version-url +V 45 +/svn/!svn/ver/33/trunk/kernel/EpiSequence.php +END +README.markdown +K 25 +svn:wc:ra_dav:version-url +V 45 +/svn/!svn/ver/33/trunk/kernel/README.markdown +END diff --git a/kernel/.svn/entries b/kernel/.svn/entries new file mode 100644 index 0000000..bf55929 --- /dev/null +++ b/kernel/.svn/entries @@ -0,0 +1,256 @@ +10 + +dir +30 +https://4sqr.googlecode.com/svn/trunk/kernel +https://4sqr.googlecode.com/svn + + + +2010-09-13T14:25:21.033276Z +30 +shizhao@gmail.com + + + + + + + + + + + + + + +d216f025-e60a-a35b-bdfd-79cb14247bae + +EpiFoursquare.php +file +33 + + + +2011-03-22T15:41:18.000000Z +27e60a72a0c6ac229b8a7ebce51d48c5 +2011-03-22T17:35:09.778978Z +33 +shizhao@gmail.com +has-props + + + + + + + + + + + + + + + + + + + + +7847 + +latitude.php +file +31 + + + +2011-03-21T15:45:09.000000Z +3a269fa378d8130f77268c04ad81e2bb +2011-03-22T17:29:28.230031Z +31 +shizhao@gmail.com + + + + + + + + + + + + + + + + + + + + + +569 + +LICENSE +file +33 + + + +2011-03-21T14:13:47.000000Z +a6f50a9c4566c24df6d80bc1f8c1f5b8 +2011-03-22T17:35:09.778978Z +33 +shizhao@gmail.com + + + + + + + + + + + + + + + + + + + + + +1479 + +foursquare.class.php +file +33 + + + + + + + + + + + + + + + + + + + +deleted + +EpiCurl.php +file +33 + + + +2011-03-21T14:13:47.000000Z +9f7d8a87574022eb78e1f7bea4f9ac03 +2011-03-22T17:35:09.778978Z +33 +shizhao@gmail.com +has-props + + + + + + + + + + + + + + + + + + + + +4823 + +EpiSequence.php +file +33 + + + +2011-03-21T14:13:47.000000Z +af97792e8781a0bcf563e49df08695af +2011-03-22T17:35:09.778978Z +33 +shizhao@gmail.com +has-props + + + + + + + + + + + + + + + + + + + + +1321 + +README.markdown +file +33 + + + +2011-03-21T14:13:47.000000Z +e4e1f18d1b4292ca93218a0d14277028 +2011-03-22T17:35:09.778978Z +33 +shizhao@gmail.com + + + + + + + + + + + + + + + + + + + + + +1193 + diff --git a/kernel/.svn/prop-base/EpiCurl.php.svn-base b/kernel/.svn/prop-base/EpiCurl.php.svn-base new file mode 100644 index 0000000..bdbd305 --- /dev/null +++ b/kernel/.svn/prop-base/EpiCurl.php.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff --git a/kernel/.svn/prop-base/EpiFoursquare.php.svn-base b/kernel/.svn/prop-base/EpiFoursquare.php.svn-base new file mode 100644 index 0000000..bdbd305 --- /dev/null +++ b/kernel/.svn/prop-base/EpiFoursquare.php.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff --git a/kernel/.svn/prop-base/EpiSequence.php.svn-base b/kernel/.svn/prop-base/EpiSequence.php.svn-base new file mode 100644 index 0000000..bdbd305 --- /dev/null +++ b/kernel/.svn/prop-base/EpiSequence.php.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff --git a/EpiCurl.php b/kernel/.svn/text-base/EpiCurl.php.svn-base similarity index 100% rename from EpiCurl.php rename to kernel/.svn/text-base/EpiCurl.php.svn-base diff --git a/kernel/.svn/text-base/EpiFoursquare.php.svn-base b/kernel/.svn/text-base/EpiFoursquare.php.svn-base new file mode 100644 index 0000000..670e567 --- /dev/null +++ b/kernel/.svn/text-base/EpiFoursquare.php.svn-base @@ -0,0 +1,263 @@ + + */ +class EpiFoursquare +{ + protected $clientId, $clientSecret, $accessToken; + protected $requestTokenUrl= 'https://foursquare.com/oauth2/authenticate'; + protected $accessTokenUrl = 'https://foursquare.com/oauth2/access_token'; + protected $authorizeUrl = 'https://foursquare.com/oauth2/authorize'; + protected $apiUrl = 'https://api.foursquare.com'; + protected $userAgent = 'EpiFoursquare (http://github.com/jmathai/foursquare-async/tree/)'; + protected $apiVersion = 'v2'; + protected $isAsynchronous = false; + protected $followLocation = false; + protected $connectionTimeout = 5; + protected $requestTimeout = 30; + protected $debug = false; + + public function getAccessToken($code, $redirectUri) + { + $params = array('client_id' => $this->clientId, 'client_secret' => $this->clientSecret, 'grant_type' => 'authorization_code', 'redirect_uri' => $redirectUri, 'code' => $code); + $qs = http_build_query($params); + return $this->request('GET', "{$this->accessTokenUrl}", $params); + } + + public function getAuthorizeUrl($redirectUri) + { + $params = array('client_id' => $this->clientId, 'response_type' => 'code', 'redirect_uri' => $redirectUri); + $qs = http_build_query($params); + return "{$this->requestTokenUrl}?{$qs}"; + } + + public function setAccessToken($accessToken) + { + $this->accessToken = $accessToken; + } + + public function setTimeout($requestTimeout = null, $connectionTimeout = null) + { + if($requestTimeout !== null) + $this->requestTimeout = floatval($requestTimeout); + if($connectionTimeout !== null) + $this->connectionTimeout = floatval($connectionTimeout); + } + + public function setUserAgent($agent) + { + $this->userAgent = $agent; + } + + public function useApiVersion($version = null) + { + $this->apiVersion = $version; + } + + public function useAsynchronous($async = true) + { + $this->isAsynchronous = (bool)$async; + } + + // Public api interface for most calls GET/POST/DELETE + public function delete($endpoint, $params = null) + { + return $this->request('DELETE', $endpoint, $params); + } + + public function get($endpoint, $params = null) + { + return $this->request('GET', $endpoint, $params); + } + + public function post($endpoint, $params = null, $up = 0) + { + return $this->request('POST', $endpoint, $params, $up); + } + + public function __construct($clientId = null, $clientSecret = null, $accessToken = null) + { + $this->clientId = $clientId; + $this->clientSecret = $clientSecret; + $this->accessToken = $accessToken; + } + + private function getApiUrl($endpoint) + { + if(!empty($this->apiVersion)) + return "{$this->apiUrl}/{$this->apiVersion}{$endpoint}"; + else + return "{$this->apiUrl}{$endpoint}"; + } + + private function request($method, $endpoint, $params = null, $up = 0) + { + if(preg_match('#^https?://#', $endpoint)) + $url = $endpoint; + else + $url = $this->getApiUrl($endpoint); + + if($this->accessToken) + { + $params['oauth_token'] = $this->accessToken; + } + else + { + $params['client_id'] = $this->clientId; + $params['client_secret'] = $this->clientSecret; + } + + if($method === 'GET') + $url .= is_null($params) ? '' : '?'.http_build_query($params, '', '&'); + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent); + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_TIMEOUT, $this->requestTimeout); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); + if(isset($_SERVER ['SERVER_ADDR']) && !empty($_SERVER['SERVER_ADDR']) && $_SERVER['SERVER_ADDR'] != '127.0.0.1') + curl_setopt($ch, CURLOPT_INTERFACE, $_SERVER ['SERVER_ADDR']); + if($method === 'POST' && $params !== null) + { + if ($up == 0) { + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); + } else { + curl_setopt($ch, CURLOPT_POSTFIELDS, $params); + } + } + + $resp = new EpiFoursquareJson(EpiCurl::getInstance()->addCurl($ch), $this->debug); + if(!$this->isAsynchronous) + $resp->responseText; + + return $resp; + } +} + +class EpiFoursquareJson implements ArrayAccess, Countable, IteratorAggregate +{ + private $debug; + private $__resp; + public function __construct($response, $debug = false) + { + $this->__resp = $response; + $this->debug = $debug; + } + + // ensure that calls complete by blocking for results, NOOP if already returned + public function __destruct() + { + $this->responseText; + } + + // Implementation of the IteratorAggregate::getIterator() to support foreach ($this as $...) + public function getIterator () + { + if ($this->__obj) { + return new ArrayIterator($this->__obj); + } else { + return new ArrayIterator($this->response); + } + } + + // Implementation of Countable::count() to support count($this) + public function count () + { + return count($this->response); + } + + // Next four functions are to support ArrayAccess interface + // 1 + public function offsetSet($offset, $value) + { + $this->response[$offset] = $value; + } + + // 2 + public function offsetExists($offset) + { + return isset($this->response[$offset]); + } + + // 3 + public function offsetUnset($offset) + { + unset($this->response[$offset]); + } + + // 4 + public function offsetGet($offset) + { + return isset($this->response[$offset]) ? $this->response[$offset] : null; + } + + public function __get($name) + { + $accessible = array('responseText'=>1,'headers'=>1,'code'=>1); + $this->responseText = $this->__resp->data; + $this->headers = $this->__resp->headers; + $this->code = $this->__resp->code; + if(isset($accessible[$name]) && $accessible[$name]) + return $this->$name; + elseif(($this->code < 200 || $this->code >= 400) && !isset($accessible[$name])) + EpiFoursquareException::raise($this->__resp, $this->debug); + + // Call appears ok so we can fill in the response + $this->response = json_decode($this->responseText, 1); + $this->__obj = json_decode($this->responseText); + + if(gettype($this->__obj) === 'object') + { + foreach($this->__obj as $k => $v) + { + $this->$k = $v; + } + } + + if (property_exists($this, $name)) { + return $this->$name; + } + return null; + } + + public function __isset($name) + { + $value = self::__get($name); + return !empty($name); + } +} + +class EpiFoursquareException extends Exception +{ + public static function raise($response, $debug) + { + $message = $response->data; + + switch($response->code) + { + case 400: + throw new EpiFoursquareBadRequestException($message, $response->code); + case 401: + throw new EpiFoursquareNotAuthorizedException($message, $response->code); + case 403: + throw new EpiFoursquareForbiddenException($message, $response->code); + case 404: + throw new EpiFoursquareNotFoundException($message, $response->code); + default: + throw new EpiFoursquareException($message, $response->code); + } + } +} +class EpiFoursquareBadRequestException extends EpiFoursquareException{} +class EpiFoursquareNotAuthorizedException extends EpiFoursquareException{} +class EpiFoursquareForbiddenException extends EpiFoursquareException{} +class EpiFoursquareNotFoundException extends EpiFoursquareException{} diff --git a/EpiSequence.php b/kernel/.svn/text-base/EpiSequence.php.svn-base similarity index 100% rename from EpiSequence.php rename to kernel/.svn/text-base/EpiSequence.php.svn-base diff --git a/LICENSE b/kernel/.svn/text-base/LICENSE.svn-base similarity index 100% rename from LICENSE rename to kernel/.svn/text-base/LICENSE.svn-base diff --git a/README.markdown b/kernel/.svn/text-base/README.markdown.svn-base similarity index 100% rename from README.markdown rename to kernel/.svn/text-base/README.markdown.svn-base diff --git a/kernel/.svn/text-base/latitude.php.svn-base b/kernel/.svn/text-base/latitude.php.svn-base new file mode 100644 index 0000000..1c2d2c3 --- /dev/null +++ b/kernel/.svn/text-base/latitude.php.svn-base @@ -0,0 +1,19 @@ +mc = curl_multi_init(); + $this->properties = array( + 'code' => CURLINFO_HTTP_CODE, + 'time' => CURLINFO_TOTAL_TIME, + 'length'=> CURLINFO_CONTENT_LENGTH_DOWNLOAD, + 'type' => CURLINFO_CONTENT_TYPE, + 'url' => CURLINFO_EFFECTIVE_URL + ); + } + + public function addCurl($ch) + { + $key = $this->getKey($ch); + $this->requests[$key] = $ch; + curl_setopt($ch, CURLOPT_HEADERFUNCTION, array($this, 'headerCallback')); + + $code = curl_multi_add_handle($this->mc, $ch); + $this->startTimer($key); + + // (1) + if($code === CURLM_OK || $code === CURLM_CALL_MULTI_PERFORM) + { + do { + $code = $this->execStatus = curl_multi_exec($this->mc, $this->running); + } while ($this->execStatus === CURLM_CALL_MULTI_PERFORM); + + return new EpiCurlManager($key); + } + else + { + return $code; + } + } + + public function getResult($key = null) + { + if($key != null) + { + if(isset($this->responses[$key])) + { + return $this->responses[$key]; + } + + $innerSleepInt = $outerSleepInt = 1; + while($this->running && ($this->execStatus == CURLM_OK || $this->execStatus == CURLM_CALL_MULTI_PERFORM)) + { + usleep($outerSleepInt); + $outerSleepInt = intval(max(1, ($outerSleepInt*$this->sleepIncrement))); + $ms=curl_multi_select($this->mc, 0); + if($ms > 0) + { + do{ + $this->execStatus = curl_multi_exec($this->mc, $this->running); + usleep($innerSleepInt); + $innerSleepInt = intval(max(1, ($innerSleepInt*$this->sleepIncrement))); + }while($this->execStatus==CURLM_CALL_MULTI_PERFORM); + $innerSleepInt = 1; + } + $this->storeResponses(); + if(isset($this->responses[$key]['data'])) + { + return $this->responses[$key]; + } + $runningCurrent = $this->running; + } + return null; + } + return false; + } + + public static function getSequence() + { + return new EpiSequence(self::$timers); + } + + public static function getTimers() + { + return self::$timers; + } + + private function getKey($ch) + { + return (string)$ch; + } + + private function headerCallback($ch, $header) + { + $_header = trim($header); + $colonPos= strpos($_header, ':'); + if($colonPos > 0) + { + $key = substr($_header, 0, $colonPos); + $val = preg_replace('/^\W+/','',substr($_header, $colonPos)); + $this->responses[$this->getKey($ch)]['headers'][$key] = $val; + } + return strlen($header); + } + + private function storeResponses() + { + while($done = curl_multi_info_read($this->mc)) + { + $key = (string)$done['handle']; + $this->stopTimer($key, $done); + $this->responses[$key]['data'] = curl_multi_getcontent($done['handle']); + foreach($this->properties as $name => $const) + { + $this->responses[$key][$name] = curl_getinfo($done['handle'], $const); + } + curl_multi_remove_handle($this->mc, $done['handle']); + curl_close($done['handle']); + } + } + + private function startTimer($key) + { + self::$timers[$key]['start'] = microtime(true); + } + + private function stopTimer($key, $done) + { + self::$timers[$key]['end'] = microtime(true); + self::$timers[$key]['api'] = curl_getinfo($done['handle'], CURLINFO_EFFECTIVE_URL); + self::$timers[$key]['time'] = curl_getinfo($done['handle'], CURLINFO_TOTAL_TIME); + self::$timers[$key]['code'] = curl_getinfo($done['handle'], CURLINFO_HTTP_CODE); + } + + static function getInstance() + { + if(self::$inst == null) + { + self::$singleton = 1; + self::$inst = new EpiCurl(); + } + + return self::$inst; + } +} + +class EpiCurlManager +{ + private $key; + private $epiCurl; + + public function __construct($key) + { + $this->key = $key; + $this->epiCurl = EpiCurl::getInstance(); + } + + public function __get($name) + { + $responses = $this->epiCurl->getResult($this->key); + return isset($responses[$name]) ? $responses[$name] : null; + } + + public function __isset($name) + { + $val = self::__get($name); + return empty($val); + } +} + +/* + * Credits: + * - (1) Alistair pointed out that curl_multi_add_handle can return CURLM_CALL_MULTI_PERFORM on success. + */ diff --git a/EpiFoursquare.php b/kernel/EpiFoursquare.php similarity index 95% rename from EpiFoursquare.php rename to kernel/EpiFoursquare.php index ab680c0..670e567 100644 --- a/EpiFoursquare.php +++ b/kernel/EpiFoursquare.php @@ -77,9 +77,9 @@ public function get($endpoint, $params = null) return $this->request('GET', $endpoint, $params); } - public function post($endpoint, $params = null) + public function post($endpoint, $params = null, $up = 0) { - return $this->request('POST', $endpoint, $params); + return $this->request('POST', $endpoint, $params, $up); } public function __construct($clientId = null, $clientSecret = null, $accessToken = null) @@ -97,7 +97,7 @@ private function getApiUrl($endpoint) return "{$this->apiUrl}{$endpoint}"; } - private function request($method, $endpoint, $params = null) + private function request($method, $endpoint, $params = null, $up = 0) { if(preg_match('#^https?://#', $endpoint)) $url = $endpoint; @@ -128,7 +128,11 @@ private function request($method, $endpoint, $params = null) curl_setopt($ch, CURLOPT_INTERFACE, $_SERVER ['SERVER_ADDR']); if($method === 'POST' && $params !== null) { - curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); + if ($up == 0) { + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); + } else { + curl_setopt($ch, CURLOPT_POSTFIELDS, $params); + } } $resp = new EpiFoursquareJson(EpiCurl::getInstance()->addCurl($ch), $this->debug); diff --git a/kernel/EpiSequence.php b/kernel/EpiSequence.php new file mode 100644 index 0000000..c47c0c2 --- /dev/null +++ b/kernel/EpiSequence.php @@ -0,0 +1,54 @@ +timers = $timers; + + $min = PHP_INT_MAX; + $max = 0; + foreach($this->timers as $timer) + { + $min = min($timer['start'], $min); + $max = max($timer['end'], $max); + } + $this->min = $min; + $this->max = $max; + $this->range = $max-$min; + $this->step = floatval($this->range/$this->width); + } + + public function renderAscii() + { + $tpl = ''; + foreach($this->timers as $timer) + $tpl .= $this->tplAscii($timer); + + return $tpl; + } + + private function tplAscii($timer) + { + $lpad = $rpad = 0; + $lspace = $chars = $rspace = ''; + if($timer['start'] > $this->min) + $lpad = intval(($timer['start'] - $this->min) / $this->step); + if($timer['end'] < $this->max) + $rpad = intval(($this->max - $timer['end']) / $this->step); + $mpad = $this->width - $lpad - $rpad; + if($lpad > 0) + $lspace = str_repeat(' ', $lpad); + if($mpad > 0) + $chars = str_repeat('=', $mpad); + if($rpad > 0) + $rspace = str_repeat(' ', $rpad); + + $tpl = <<post('/checkins/add', array( + 'venueId' => '35610', 'broadcast' => 'public' + ) + ); + echo "You've checked in a total of {$checkin->response->checkins->count} times"; + + +### Documentation + +There's complete documentation available on Github at .. + +### The authors + +Get in touch with the authors if you have suggestions or questions. + + + + +
Jaisen Mathai
jaisen-at-jmathai.com
http://www.jaisenmathai.com
diff --git a/kernel/latitude.php b/kernel/latitude.php new file mode 100644 index 0000000..d4704c0 --- /dev/null +++ b/kernel/latitude.php @@ -0,0 +1,27 @@ + diff --git a/logo.png b/logo.png new file mode 100644 index 0000000..ab03da9 Binary files /dev/null and b/logo.png differ diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..0855523 --- /dev/null +++ b/logout.php @@ -0,0 +1,4 @@ + diff --git a/places.php b/places.php new file mode 100644 index 0000000..b309afb --- /dev/null +++ b/places.php @@ -0,0 +1,27 @@ + + + + + + + +

+$name - $vic
"; +} +echo "
Add venue
"; +echo "I at here!
"; +?> +
+Power by 4sqr. +
+ + diff --git a/robots.txt b/robots.txt new file mode 100644 index 0000000..1f53798 --- /dev/null +++ b/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: / diff --git a/signinwith-foursquare.png b/signinwith-foursquare.png new file mode 100644 index 0000000..3c0df80 Binary files /dev/null and b/signinwith-foursquare.png differ diff --git a/simpleTest.php b/simpleTest.php index 5f0d3c5..63ea3b8 100644 --- a/simpleTest.php +++ b/simpleTest.php @@ -1,7 +1,7 @@ response); ?> -
\ No newline at end of file +