Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
smarandal-telenav committed Jul 22, 2016
0 parents commit 7f9da68
Show file tree
Hide file tree
Showing 5,094 changed files with 760,631 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* -crlf
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
files/
.DS_*
cache/*
tmp/*
nbproject/
desktop.ini
66 changes: 66 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# BEGIN Compress text files
<ifModule mod_deflate.c>
<filesMatch ".(css|js|x?html?|php)$">
SetOutputFilter DEFLATE
</filesMatch>
</ifModule>
# END Compress text files

# BEGIN EXPIRES
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 10 days"
ExpiresByType text/css "access plus 1 week"
ExpiresByType text/plain "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType application/x-icon "access plus 1 year"
</IfModule>
# END EXPIRES

# BEGIN Cache-Control Headers
<ifModule mod_headers.c>
<filesMatch ".(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
<filesMatch ".(css)$">
Header set Cache-Control "max-age=604800, public"
</filesMatch>
<filesMatch ".(js)$">
Header set Cache-Control "max-age=216000, private"
</filesMatch>
</ifModule>
# END Cache-Control Headers

# BEGIN Turn ETags Off
<ifModule mod_headers.c>
Header unset ETag
</ifModule>
FileETag None
# END Turn ETags Off

# BEGIN Remove Last-Modified Header
<ifModule mod_headers.c>
Header unset Last-Modified
</ifModule>
# END Remove Last-Modified Header

<IfModule mod_rewrite.c>
RewriteEngine on
#next line is to be changed into app root directory name
RewriteBase /

#RewriteCond %{REQUEST_URI} !(/$|\.)
#RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]

RewriteCond %{HTTP_USER_AGENT} (.*facebookexternalhit.*|.*Twitterbot.*|.*Pinterest.*|.*Google.*|.*Slackbot.*|.*Facebot.*|.*Skype.*|.*facebook.*|.*FB_IAB.*|.*FBAN\/FBIOS.*|.*FBAV.*|.*FBBV.*|.*FBDV.*|.*FBMD.*|.*FBSN.*|.*FBCR.*|.*FBLC.*|.*Slackbot-LinkExpanding.*)$
RewriteRule ^details/(.*)/(.*)$ /opengraph?sequence=$1&index=$2 [P]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

</IfModule>

7 changes: 7 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
The code is licensed under the LGPL Version 3 license
http://www.gnu.org/licenses/lgpl-3.0.en.html.

The collected imagery is protected & available under the CC BY-SA version 4 International license.
https://creativecommons.org/licenses/by-sa/4.0/legalcode.

Copyright ©2016, Telenav, Inc. All Rights Reserved
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
OpenStreetView
=============================

This is OpenStreetView.org

OpenStreetView collects, stores and distributes georeferenced street view imagery with the purpose to help the OSM community improve OpenStreetMap (https://www.openstreetmap.org/).

Installation
------------

License
-------

The collected imagery is protected & available under the CC BY-SA version 4 International license.
https://creativecommons.org/licenses/by-sa/4.0/legalcode.

The code is licensed under the LGPL Version 3 license
http://www.gnu.org/licenses/lgpl-3.0.en.html.

Copyright ©2016, Telenav, Inc. All Rights Reserved
32 changes: 32 additions & 0 deletions app/OsvApp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

/*
* This file is part of the openstreetview.org
*
* Copyright ©2016, Telenav, Inc. All Rights Reserved
*
* The code is licensed under the LGPL Version 3 license
* http://www.gnu.org/licenses/lgpl-3.0.en.html.
*/

class OsvApp {
static private $_app;

static public function setApp(&$app)
{
self::$_app = $app;
}

static public function getApp()
{
return self::$_app?self::$_app:null;
}

static public function getResource($key)
{
if (isset(self::$_app[$key])) {
return self::$_app[$key];
}
return false;
}
}
33 changes: 33 additions & 0 deletions app/config/constants.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/*
* This file is part of the openstreetview.org
*
* Copyright ©2016, Telenav, Inc. All Rights Reserved
*
* The code is licensed under the LGPL Version 3 license
* http://www.gnu.org/licenses/lgpl-3.0.en.html.
*/
define('API_CODE_OK', '600: The request has been processed without incidents ');
define('API_CODE_EMPTY_RESULT', '601: The request has an empty response ');
define('API_CODE_POSSIBLY_INACCURATE', '602: The request has been processed but there have been incidents');

define('API_CODE_MISSING_ARGUMENT' , '610: A required argument is missing ');
define('API_CODE_INVALID_ARGUMENT' , '611: An argument has the wrong type ');
define('API_CODE_OUT_OF_RANGE_ARGUMENT', '612: An argument is out of range ');
define('API_CODE_INVALID_REQUEST_BODY', '613: Invalid request body.');
define('API_CODE_ACCESS_DENIED', '618: You are not allowed to perform this operation.');
define('API_CODE_DUPLICATE_ENTRY', '660: You are not allowed to add a duplicate entry ');

define('API_CODE_INCORRECT_STATUS', '671: The status is incorrect.');

define('AUTHENTICATION_REQUIRED', '401: You have to be authenticated in order to access this method');
define('API_CODE_UNEXPECTED_SERVER_ERROR', '690: An unexpected server error has occurred');

define('HTTP_CODE_BAD_REQUEST', 'Bad Request');
define('HTTP_CODE_SUCCESS', 'Success');

define('OSM_API_KEY', '******************************62L*****');
define('OSM_API_SECRET', '******************************duixu****');
define('API_VERSION', '1.0');
define('PATH_FILES_PHOTO', 'files/photo');
36 changes: 36 additions & 0 deletions app/config/settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
development:
debug: true
database:
driver: pdo_mysql
host: localhost
dbname: openstreetview
user: root
password:
charset: utf8
NBService:
MRService:
minify: false
testing:
debug: false
database:
driver: pdo_mysql
host: localhost
dbname:
user:
password:
charset: utf8
NBService:
MRService:
minify: true
production:
debug: false
database:
driver: pdo_mysql
host:
dbname:
user:
password:
charset: utf8
NBService:
MRService:
minify: true
33 changes: 33 additions & 0 deletions app/controllers/OSVAppController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/*
* This file is part of the openstreetview.org
*
* Copyright ©2016, Telenav, Inc. All Rights Reserved
*
* The code is licensed under the LGPL Version 3 license
* http://www.gnu.org/licenses/lgpl-3.0.en.html.
*/

use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Intl\Intl;

class OSVAppController{
public function index(Application $app){
$request = $app['request'];
return json_encode(array('version' => API_VERSION)) ;
}

public function downloadApp(Application $app){
$request = $app['request'];
return "to be implemented" ;
}
}
104 changes: 104 additions & 0 deletions app/controllers/OSVDetailsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php

/*
* This file is part of the openstreetview.org
*
* Copyright ©2016, Telenav, Inc. All Rights Reserved
*
* The code is licensed under the LGPL Version 3 license
* http://www.gnu.org/licenses/lgpl-3.0.en.html.
*/

use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Form\FormBuilder;

use OAuth\OAuth1\Service\OpenStreetMap;

class OSVDetailsController{

public function index(Application $app){
$request = $app['request'];
if(is_null($request->get('form', null))) {
$postData = array(
'id' => $request->request->get('id', null),
'platform' => $request->request->get('platform', null)
);
} else {
$postData = $request->get('form');
}
$constraint = new Assert\Collection(array(
'id' => new Assert\NotBlank(),
'platform' => new Assert\Optional(),
));

$errors = $app['validator']->validateValue($postData, $constraint);
if (count($errors) > 0) {
foreach($errors as $error){
$frc = new OSVResponseController($app, null, $error);
return $frc->jsonResponse;
}
}
$photoList = new OSVListProvider();
$photo = new OSVPhotoProvider();
$osvSequence = new OSVSequenceProvider();
$osvUser = new UserProvider();
$response = null;
$error = null;
try {
$sequence = $osvSequence->get($app, $postData['id']);
if (empty($sequence)) {
$error = new Exception(API_CODE_EMPTY_RESULT, 601);
} else if($app['security.authorization_checker']->isGranted('view', $sequence)){
$owner = $osvUser->get($app, $sequence->userId);
$privacyLevel = 1; //not the sequence owner
$response = array(
'date_added' => date('M d, Y', strtotime(substr($sequence->dateAdded, 0, 10))),
'platform' => $sequence->platformName,
'user' => $owner->username,
'meta_data_filename' => $sequence->metaDataFilename,
'address' => $sequence->address,
'reviewed' => $sequence->reviewed,
'changed' => $sequence->changes,
'obd_info' => $sequence->obdInfo,
'count_active_photos' => $sequence->countActivePhotos,
'recognitions' => $sequence->recognitions,
'owner' => (isset($app['user']) && !empty($app['user']) && $sequence->userId == $app['user']->getId()) ? true : false
);

$photos = $photo->getSequence($app, $postData['id'], $privacyLevel);
$response['photos'] = $photos;
if(empty($photoList)){
$error = new Exception(API_CODE_EMPTY_RESULT, 601);
$frc = new OSVResponseController($app, null, $error);
return $frc->jsonResponse;
}
} else {
$error = new Exception(API_CODE_ACCESS_DENIED, 618);
}
} catch (Exception $ex) {
$error = new \Symfony\Component\Config\Definition\Exception\Exception(API_CODE_UNEXPECTED_SERVER_ERROR, 690);

}
$frc = new OSVResponseController($app, $response, $error, isset($apiMessage)?$apiMessage:null);
return $frc->jsonResponse;
}

protected function isMobile()
{
$useragent = $_SERVER['HTTP_USER_AGENT'];

if(preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$useragent) || preg_match('/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i',substr($useragent,0,4))) {
return true;

}
return false;
}

}
Loading

0 comments on commit 7f9da68

Please sign in to comment.