@@ -0,0 +1,13 @@ | |||
{ | |||
"name": "vendor/g-i-s-a-p-i", | |||
"description": "Description of project GIS API.", | |||
"authors": [ | |||
{ | |||
"name": "skylar", | |||
"email": "your@email.here" | |||
} | |||
], | |||
"require": { | |||
"catfan/medoo": "^1.1" | |||
} | |||
} |
@@ -0,0 +1,74 @@ | |||
{ | |||
"_readme": [ | |||
"This file locks the dependencies of your project to a known state", | |||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", | |||
"This file is @generated automatically" | |||
], | |||
"hash": "14739f64042726cd1da2fc3588dd655d", | |||
"content-hash": "a04c7422846ed42285920bcc09babfd3", | |||
"packages": [ | |||
{ | |||
"name": "catfan/medoo", | |||
"version": "v1.1.3", | |||
"source": { | |||
"type": "git", | |||
"url": "https://github.com/catfan/Medoo.git", | |||
"reference": "2601ffd53971866695c544c955d580d3d36b3848" | |||
}, | |||
"dist": { | |||
"type": "zip", | |||
"url": "https://api.github.com/repos/catfan/Medoo/zipball/2601ffd53971866695c544c955d580d3d36b3848", | |||
"reference": "2601ffd53971866695c544c955d580d3d36b3848", | |||
"shasum": "" | |||
}, | |||
"require": { | |||
"ext-pdo": "*", | |||
"php": ">=5.1" | |||
}, | |||
"suggest": { | |||
"ext-pdo_dblib": "For MSSQL or Sybase databases on Linux/UNIX platform", | |||
"ext-pdo_mysql": "For MySQL or MariaDB databases", | |||
"ext-pdo_oci": "For Oracle databases", | |||
"ext-pdo_pqsql": "For PostgreSQL databases", | |||
"ext-pdo_sqlite": "For SQLite databases", | |||
"ext-pdo_sqlsrv": "For MSSQL databases on Windows platform" | |||
}, | |||
"type": "framework", | |||
"autoload": { | |||
"files": [ | |||
"medoo.php" | |||
] | |||
}, | |||
"notification-url": "https://packagist.org/downloads/", | |||
"license": [ | |||
"MIT" | |||
], | |||
"authors": [ | |||
{ | |||
"name": "Angel Lai", | |||
"email": "angel@catfan.me" | |||
} | |||
], | |||
"description": "The Lightest PHP database framework to accelerate development", | |||
"homepage": "http://medoo.in", | |||
"keywords": [ | |||
"database", | |||
"lightweight", | |||
"mssql", | |||
"mysql", | |||
"php framework", | |||
"sql", | |||
"sqlite" | |||
], | |||
"time": "2016-09-05 07:18:35" | |||
} | |||
], | |||
"packages-dev": [], | |||
"aliases": [], | |||
"minimum-stability": "stable", | |||
"stability-flags": [], | |||
"prefer-stable": false, | |||
"prefer-lowest": false, | |||
"platform": [], | |||
"platform-dev": [] | |||
} |
@@ -0,0 +1,20 @@ | |||
<!DOCTYPE html> | |||
<!-- | |||
To change this license header, choose License Headers in Project Properties. | |||
To change this template file, choose Tools | Templates | |||
and open the template in the editor. | |||
--> | |||
<html> | |||
<head> | |||
<meta charset="UTF-8"> | |||
<title>GIS Server</title> | |||
</head> | |||
<body> | |||
<h1>TerranQuest GIS Server</h1> | |||
<p> | |||
This server handles the global terrain data for TerranQuest. | |||
To request an API key for your server, go here: | |||
<a href="https://netsyms.com/#contact">https://netsyms.com/#contact</a> | |||
</p> | |||
</body> | |||
</html> |
@@ -0,0 +1,7 @@ | |||
include.path=${php.global.include.path} | |||
php.version=PHP_56 | |||
source.encoding=UTF-8 | |||
src.dir=. | |||
tags.asp=false | |||
tags.short=false | |||
web.root=. |
@@ -0,0 +1,9 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project xmlns="http://www.netbeans.org/ns/project/1"> | |||
<type>org.netbeans.modules.php.project</type> | |||
<configuration> | |||
<data xmlns="http://www.netbeans.org/ns/php-project/1"> | |||
<name>GIS API</name> | |||
</data> | |||
</configuration> | |||
</project> |
@@ -0,0 +1,67 @@ | |||
<?php | |||
/** | |||
* This file contains global settings and things that should be loaded at the | |||
* top of each file. | |||
*/ | |||
header("Access-Control-Allow-Origin: *"); | |||
header('Content-Type: application/json'); | |||
// Composer | |||
require 'vendor/autoload.php'; | |||
// API response formatters | |||
require 'response.php'; | |||
// Settings file | |||
require 'settings.php'; | |||
// Init database and stuff | |||
$database; | |||
try { | |||
$database = new medoo([ | |||
'database_type' => DB_TYPE, | |||
'database_name' => DB_NAME, | |||
'server' => DB_SERVER, | |||
'username' => DB_USER, | |||
'password' => DB_PASS, | |||
'charset' => DB_CHARSET | |||
]); | |||
} catch (Exception $ex) { | |||
header('HTTP/1.1 500 Internal Server Error'); | |||
sendError('Database error. Try again later.', true); | |||
} | |||
if (!DEBUG) { | |||
error_reporting(0); | |||
} else { | |||
error_reporting(E_ALL); | |||
ini_set('display_errors', 'On'); | |||
} | |||
$VARS; | |||
if ($_SERVER['REQUEST_METHOD'] === 'POST') { | |||
$VARS = $_POST; | |||
define("GET", false); | |||
} else { | |||
$VARS = $_GET; | |||
define("GET", true); | |||
} | |||
/** | |||
* Checks if a string or whatever is empty. | |||
* @param $str The thingy to check | |||
* @return boolean True if it's empty or whatever. | |||
*/ | |||
function is_empty($str) { | |||
return (!isset($str) || $str == '' || $str == null); | |||
} | |||
if (is_empty($VARS['key'])) { | |||
sendError('Please supply an API key (?key=abc)', true); | |||
} | |||
if (!$database->has('apikeys', ["AND" => ['apikey' => $VARS['key'], "active" => 1]])) { | |||
sendError('Invalid or inactive API key.', true); | |||
} |
@@ -0,0 +1,27 @@ | |||
<?php | |||
function sendOK($message = "", $die = false) { | |||
if (!is_empty($message) && JSON) { | |||
echo '{ "status": "OK", "message": "'.$message.'" }'; | |||
} elseif (is_empty($message) && JSON) { | |||
echo '{ "status": "OK" }'; | |||
} elseif (!is_empty($message) && !JSON) { | |||
echo "OK:$message"; | |||
} else { | |||
echo "OK"; | |||
} | |||
if ($die) { | |||
die(); | |||
} | |||
} | |||
function sendError($error, $die = false) { | |||
if (JSON) { | |||
echo '{ "status": "ERROR", "message": "' . $error . '" }'; | |||
} else { | |||
echo "Error: $error"; | |||
} | |||
if ($die) { | |||
die(); | |||
} | |||
} |
@@ -0,0 +1,10 @@ | |||
<?php | |||
define("DEBUG", false); | |||
define("DB_TYPE", "mysql"); | |||
define("DB_NAME", "terrain"); | |||
define("DB_SERVER", "localhost"); | |||
define("DB_USER", "terrain"); | |||
define("DB_PASS", ""); | |||
define("DB_CHARSET", "latin1"); |
@@ -0,0 +1,23 @@ | |||
<?php | |||
require 'required.php'; | |||
// Validate input | |||
if (is_empty($VARS['lat']) || is_empty($VARS['long'])) { | |||
sendError("Missing information.", true); | |||
} | |||
if (!preg_match('/-?[0-9]{1,3}\.[0-9]{2,}/', $VARS['lat'])) { | |||
sendError("Latitude (lat) is in the wrong format.", true); | |||
} | |||
if (!preg_match('/-?[0-9]{1,3}\.[0-9]{2,}/', $VARS['long'])) { | |||
sendError("Longitude (long) is in the wrong format.", true); | |||
} | |||
// Round to 2 digits (approx. 1.1km) | |||
$lat = number_format((float) $VARS['lat'], 2, '.', ''); | |||
$long = number_format((float) $VARS['long'], 2, '.', ''); | |||
$terrainid = $database->select('terrain', 'type', ["AND" => ["latitude" => $lat, "longitude" => $long]])[0]; | |||
$out = ["status" => "OK", "type" => $terrainid]; | |||
echo json_encode($out); |
@@ -0,0 +1,7 @@ | |||
<?php | |||
// autoload.php @generated by Composer | |||
require_once __DIR__ . '/composer' . '/autoload_real.php'; | |||
return ComposerAutoloaderInitced6a9042f97dd8b342a978ca0b1aac0::getLoader(); |
@@ -0,0 +1,22 @@ | |||
# Auto detect text files and perform LF normalization | |||
* text=auto | |||
# Custom for Visual Studio | |||
*.cs diff=csharp | |||
*.sln merge=union | |||
*.csproj merge=union | |||
*.vbproj merge=union | |||
*.fsproj merge=union | |||
*.dbproj merge=union | |||
# Standard to msysgit | |||
*.doc diff=astextplain | |||
*.DOC diff=astextplain | |||
*.docx diff=astextplain | |||
*.DOCX diff=astextplain | |||
*.dot diff=astextplain | |||
*.DOT diff=astextplain | |||
*.pdf diff=astextplain | |||
*.PDF diff=astextplain | |||
*.rtf diff=astextplain | |||
*.RTF diff=astextplain |
@@ -0,0 +1,163 @@ | |||
################# | |||
## Eclipse | |||
################# | |||
*.pydevproject | |||
.project | |||
.metadata | |||
bin/ | |||
tmp/ | |||
*.tmp | |||
*.bak | |||
*.swp | |||
*~.nib | |||
local.properties | |||
.classpath | |||
.settings/ | |||
.loadpath | |||
# External tool builders | |||
.externalToolBuilders/ | |||
# Locally stored "Eclipse launch configurations" | |||
*.launch | |||
# CDT-specific | |||
.cproject | |||
# PDT-specific | |||
.buildpath | |||
################# | |||
## Visual Studio | |||
################# | |||
## Ignore Visual Studio temporary files, build results, and | |||
## files generated by popular Visual Studio add-ons. | |||
# User-specific files | |||
*.suo | |||
*.user | |||
*.sln.docstates | |||
# Build results | |||
[Dd]ebug/ | |||
[Rr]elease/ | |||
*_i.c | |||
*_p.c | |||
*.ilk | |||
*.meta | |||
*.obj | |||
*.pch | |||
*.pdb | |||
*.pgc | |||
*.pgd | |||
*.rsp | |||
*.sbr | |||
*.tlb | |||
*.tli | |||
*.tlh | |||
*.tmp | |||
*.vspscc | |||
.builds | |||
*.dotCover | |||
## TODO: If you have NuGet Package Restore enabled, uncomment this | |||
#packages/ | |||
# Visual C++ cache files | |||
ipch/ | |||
*.aps | |||
*.ncb | |||
*.opensdf | |||
*.sdf | |||
# Visual Studio profiler | |||
*.psess | |||
*.vsp | |||
# ReSharper is a .NET coding add-in | |||
_ReSharper* | |||
# Installshield output folder | |||
[Ee]xpress | |||
# DocProject is a documentation generator add-in | |||
DocProject/buildhelp/ | |||
DocProject/Help/*.HxT | |||
DocProject/Help/*.HxC | |||
DocProject/Help/*.hhc | |||
DocProject/Help/*.hhk | |||
DocProject/Help/*.hhp | |||
DocProject/Help/Html2 | |||
DocProject/Help/html | |||
# Click-Once directory | |||
publish | |||
# Others | |||
[Bb]in | |||
[Oo]bj | |||
sql | |||
TestResults | |||
*.Cache | |||
ClientBin | |||
stylecop.* | |||
~$* | |||
*.dbmdl | |||
Generated_Code #added for RIA/Silverlight projects | |||
# Backup & report files from converting an old project file to a newer | |||
# Visual Studio version. Backup files are not needed, because we have git ;-) | |||
_UpgradeReport_Files/ | |||
Backup*/ | |||
UpgradeLog*.XML | |||
############ | |||
## Windows | |||
############ | |||
# Windows image file caches | |||
Thumbs.db | |||
# Folder config file | |||
Desktop.ini | |||
############# | |||
## Python | |||
############# | |||
*.py[co] | |||
# Packages | |||
*.egg | |||
*.egg-info | |||
dist | |||
build | |||
eggs | |||
parts | |||
bin | |||
var | |||
sdist | |||
develop-eggs | |||
.installed.cfg | |||
# Installer logs | |||
pip-log.txt | |||
# Unit test / coverage reports | |||
.coverage | |||
.tox | |||
#Translations | |||
*.mo | |||
#Mr Developer | |||
.mr.developer.cfg | |||
# Mac crap | |||
.DS_Store |
@@ -0,0 +1,22 @@ | |||
[MIT LICENSE] | |||
Copyright (c) 2016 Angel Lai, http://medoo.in | |||
Permission is hereby granted, free of charge, to any person obtaining | |||
a copy of this software and associated documentation files (the | |||
Software), to deal in the Software without restriction, including | |||
without limitation the rights to use, copy, modify, merge, publish, | |||
distribute, sublicense, andor sell copies of the Software, and to | |||
permit persons to whom the Software is furnished to do so, subject to | |||
the following conditions | |||
The above copyright notice and this permission notice shall be | |||
included in all copies or substantial portions of the Software. | |||
THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, | |||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | |||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | |||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
@@ -0,0 +1,77 @@ | |||
 | |||
## [Medoo](http://medoo.in) | |||
> The Lightest PHP database framework to accelerate development | |||
## Main Features | |||
* **Lightweight** - 20KB around with only one file. | |||
* **Easy** - Extremely easy to learn and use, friendly construction. | |||
* **Powerful** - Support various common and complex SQL queries. | |||
* **Compatible** - Support various SQL database, including MySQL, MSSQL, SQLite, MariaDB, Sybase, Oracle, PostgreSQL and more. | |||
* **Security** - Prevent SQL injection. | |||
* **Free** - Under MIT license, you can use it anywhere if you want. | |||
## Get Started | |||
### Install via composer | |||
Add Medoo to composer.json configuration file. | |||
``` | |||
$ composer require catfan/Medoo | |||
``` | |||
And update the composer | |||
``` | |||
$ composer update | |||
``` | |||
```php | |||
// If you installed via composer, just use this code to requrie autoloader on the top of your projects. | |||
require 'vendor/autoload.php'; | |||
// Or if you just download the medoo.php into directory, require it with the correct path. | |||
require_once 'medoo.php'; | |||
// Initialize | |||
$database = new medoo([ | |||
'database_type' => 'mysql', | |||
'database_name' => 'name', | |||
'server' => 'localhost', | |||
'username' => 'your_username', | |||
'password' => 'your_password', | |||
'charset' => 'utf8' | |||
]); | |||
// Enjoy | |||
$database->insert('account', [ | |||
'user_name' => 'foo', | |||
'email' => 'foo@bar.com', | |||
'age' => 25, | |||
'lang' => ['en', 'fr', 'jp', 'cn'] | |||
]); | |||
``` | |||
## Contribution Guides | |||
For most of time, Medoo is using develop branch for adding feature and fixing bug, and the branch will be merged into master branch while releasing a public version. For contribution, submit your code to the develop branch, and start a pull request into it. | |||
On develop branch, each commits are started with `[fix]`, `[feature]` or `[update]` tag to indicate the change. | |||
Keep it simple and keep it clear. | |||
## License | |||
Medoo is under the MIT license. | |||
## Links | |||
* Official website: [http://medoo.in](http://medoo.in) | |||
* Documentation: [http://medoo.in/doc](http://medoo.in/doc) |
@@ -0,0 +1,26 @@ | |||
{ | |||
"name": "catfan/medoo", | |||
"type": "framework", | |||
"description": "The Lightest PHP database framework to accelerate development", | |||
"keywords": ["database", "lightweight", "PHP framework", "SQL", "MySQL", "MSSQL", "SQLite"], | |||
"homepage": "http://medoo.in", | |||
"license": "MIT", | |||
"authors": [ | |||
{"name": "Angel Lai", "email": "angel@catfan.me"} | |||
], | |||
"require": { | |||
"php": ">=5.1", | |||
"ext-pdo": "*" | |||
}, | |||
"suggest": { | |||
"ext-pdo_mysql": "For MySQL or MariaDB databases", | |||
"ext-pdo_sqlsrv": "For MSSQL databases on Windows platform", | |||
"ext-pdo_dblib": "For MSSQL or Sybase databases on Linux/UNIX platform", | |||
"ext-pdo_oci": "For Oracle databases", | |||
"ext-pdo_pqsql": "For PostgreSQL databases", | |||
"ext-pdo_sqlite": "For SQLite databases" | |||
}, | |||
"autoload": { | |||
"files": ["medoo.php"] | |||
} | |||
} |
@@ -0,0 +1,413 @@ | |||
<?php | |||
/* | |||
* This file is part of Composer. | |||
* | |||
* (c) Nils Adermann <naderman@naderman.de> | |||
* Jordi Boggiano <j.boggiano@seld.be> | |||
* | |||
* For the full copyright and license information, please view the LICENSE | |||
* file that was distributed with this source code. | |||
*/ | |||
namespace Composer\Autoload; | |||
/** | |||
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader. | |||
* | |||
* $loader = new \Composer\Autoload\ClassLoader(); | |||
* | |||
* // register classes with namespaces | |||
* $loader->add('Symfony\Component', __DIR__.'/component'); | |||
* $loader->add('Symfony', __DIR__.'/framework'); | |||
* | |||
* // activate the autoloader | |||
* $loader->register(); | |||
* | |||
* // to enable searching the include path (eg. for PEAR packages) | |||
* $loader->setUseIncludePath(true); | |||
* | |||
* In this example, if you try to use a class in the Symfony\Component | |||
* namespace or one of its children (Symfony\Component\Console for instance), | |||
* the autoloader will first look for the class under the component/ | |||
* directory, and it will then fallback to the framework/ directory if not | |||
* found before giving up. | |||
* | |||
* This class is loosely based on the Symfony UniversalClassLoader. | |||
* | |||
* @author Fabien Potencier <fabien@symfony.com> | |||
* @author Jordi Boggiano <j.boggiano@seld.be> | |||
* @see http://www.php-fig.org/psr/psr-0/ | |||
* @see http://www.php-fig.org/psr/psr-4/ | |||
*/ | |||
class ClassLoader | |||
{ | |||
// PSR-4 | |||
private $prefixLengthsPsr4 = array(); | |||
private $prefixDirsPsr4 = array(); | |||
private $fallbackDirsPsr4 = array(); | |||
// PSR-0 | |||
private $prefixesPsr0 = array(); | |||
private $fallbackDirsPsr0 = array(); | |||
private $useIncludePath = false; | |||
private $classMap = array(); | |||
private $classMapAuthoritative = false; | |||
public function getPrefixes() | |||
{ | |||
if (!empty($this->prefixesPsr0)) { | |||
return call_user_func_array('array_merge', $this->prefixesPsr0); | |||
} | |||
return array(); | |||
} | |||
public function getPrefixesPsr4() | |||
{ | |||
return $this->prefixDirsPsr4; | |||
} | |||
public function getFallbackDirs() | |||
{ | |||
return $this->fallbackDirsPsr0; | |||
} | |||
public function getFallbackDirsPsr4() | |||
{ | |||
return $this->fallbackDirsPsr4; | |||
} | |||
public function getClassMap() | |||
{ | |||
return $this->classMap; | |||
} | |||
/** | |||
* @param array $classMap Class to filename map | |||
*/ | |||
public function addClassMap(array $classMap) | |||
{ | |||
if ($this->classMap) { | |||
$this->classMap = array_merge($this->classMap, $classMap); | |||
} else { | |||
$this->classMap = $classMap; | |||
} | |||
} | |||
/** | |||
* Registers a set of PSR-0 directories for a given prefix, either | |||
* appending or prepending to the ones previously set for this prefix. | |||
* | |||
* @param string $prefix The prefix | |||
* @param array|string $paths The PSR-0 root directories | |||
* @param bool $prepend Whether to prepend the directories | |||
*/ | |||
public function add($prefix, $paths, $prepend = false) | |||
{ | |||
if (!$prefix) { | |||
if ($prepend) { | |||
$this->fallbackDirsPsr0 = array_merge( | |||
(array) $paths, | |||
$this->fallbackDirsPsr0 | |||
); | |||
} else { | |||
$this->fallbackDirsPsr0 = array_merge( | |||
$this->fallbackDirsPsr0, | |||
(array) $paths | |||
); | |||
} | |||
return; | |||
} | |||
$first = $prefix[0]; | |||
if (!isset($this->prefixesPsr0[$first][$prefix])) { | |||
$this->prefixesPsr0[$first][$prefix] = (array) $paths; | |||
return; | |||
} | |||
if ($prepend) { | |||
$this->prefixesPsr0[$first][$prefix] = array_merge( | |||
(array) $paths, | |||
$this->prefixesPsr0[$first][$prefix] | |||
); | |||
} else { | |||
$this->prefixesPsr0[$first][$prefix] = array_merge( | |||
$this->prefixesPsr0[$first][$prefix], | |||
(array) $paths | |||
); | |||
} | |||
} | |||
/** | |||
* Registers a set of PSR-4 directories for a given namespace, either | |||
* appending or prepending to the ones previously set for this namespace. | |||
* | |||
* @param string $prefix The prefix/namespace, with trailing '\\' | |||
* @param array|string $paths The PSR-4 base directories | |||
* @param bool $prepend Whether to prepend the directories | |||
* | |||
* @throws \InvalidArgumentException | |||
*/ | |||
public function addPsr4($prefix, $paths, $prepend = false) | |||
{ | |||
if (!$prefix) { | |||
// Register directories for the root namespace. | |||
if ($prepend) { | |||
$this->fallbackDirsPsr4 = array_merge( | |||
(array) $paths, | |||
$this->fallbackDirsPsr4 | |||
); | |||
} else { | |||
$this->fallbackDirsPsr4 = array_merge( | |||
$this->fallbackDirsPsr4, | |||
(array) $paths | |||
); | |||
} | |||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) { | |||
// Register directories for a new namespace. | |||
$length = strlen($prefix); | |||
if ('\\' !== $prefix[$length - 1]) { | |||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); | |||
} | |||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; | |||
$this->prefixDirsPsr4[$prefix] = (array) $paths; | |||
} elseif ($prepend) { | |||
// Prepend directories for an already registered namespace. | |||
$this->prefixDirsPsr4[$prefix] = array_merge( | |||
(array) $paths, | |||
$this->prefixDirsPsr4[$prefix] | |||
); | |||
} else { | |||
// Append directories for an already registered namespace. | |||
$this->prefixDirsPsr4[$prefix] = array_merge( | |||
$this->prefixDirsPsr4[$prefix], | |||
(array) $paths | |||
); | |||
} | |||
} | |||
/** | |||
* Registers a set of PSR-0 directories for a given prefix, | |||
* replacing any others previously set for this prefix. | |||
* | |||
* @param string $prefix The prefix | |||
* @param array|string $paths The PSR-0 base directories | |||
*/ | |||
public function set($prefix, $paths) | |||
{ | |||
if (!$prefix) { | |||
$this->fallbackDirsPsr0 = (array) $paths; | |||
} else { | |||
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; | |||
} | |||
} | |||
/** | |||
* Registers a set of PSR-4 directories for a given namespace, | |||
* replacing any others previously set for this namespace. | |||
* | |||
* @param string $prefix The prefix/namespace, with trailing '\\' | |||
* @param array|string $paths The PSR-4 base directories | |||
* | |||
* @throws \InvalidArgumentException | |||
*/ | |||
public function setPsr4($prefix, $paths) | |||
{ | |||
if (!$prefix) { | |||
$this->fallbackDirsPsr4 = (array) $paths; | |||
} else { | |||
$length = strlen($prefix); | |||
if ('\\' !== $prefix[$length - 1]) { | |||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); | |||
} | |||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; | |||
$this->prefixDirsPsr4[$prefix] = (array) $paths; | |||
} | |||
} | |||
/** | |||
* Turns on searching the include path for class files. | |||
* | |||
* @param bool $useIncludePath | |||
*/ | |||
public function setUseIncludePath($useIncludePath) | |||
{ | |||
$this->useIncludePath = $useIncludePath; | |||
} | |||
/** | |||
* Can be used to check if the autoloader uses the include path to check | |||
* for classes. | |||
* | |||
* @return bool | |||
*/ | |||
public function getUseIncludePath() | |||
{ | |||
return $this->useIncludePath; | |||
} | |||
/** | |||
* Turns off searching the prefix and fallback directories for classes | |||
* that have not been registered with the class map. | |||
* | |||
* @param bool $classMapAuthoritative | |||
*/ | |||
public function setClassMapAuthoritative($classMapAuthoritative) | |||
{ | |||
$this->classMapAuthoritative = $classMapAuthoritative; | |||
} | |||
/** | |||
* Should class lookup fail if not found in the current class map? | |||
* | |||
* @return bool | |||
*/ | |||
public function isClassMapAuthoritative() | |||
{ | |||
return $this->classMapAuthoritative; | |||
} | |||
/** | |||
* Registers this instance as an autoloader. | |||
* | |||
* @param bool $prepend Whether to prepend the autoloader or not | |||
*/ | |||
public function register($prepend = false) | |||
{ | |||
spl_autoload_register(array($this, 'loadClass'), true, $prepend); | |||
} | |||
/** | |||
* Unregisters this instance as an autoloader. | |||
*/ | |||
public function unregister() | |||
{ | |||
spl_autoload_unregister(array($this, 'loadClass')); | |||
} | |||
/** | |||
* Loads the given class or interface. | |||
* | |||
* @param string $class The name of the class | |||
* @return bool|null True if loaded, null otherwise | |||
*/ | |||
public function loadClass($class) | |||
{ | |||
if ($file = $this->findFile($class)) { | |||
includeFile($file); | |||
return true; | |||
} | |||
} | |||
/** | |||
* Finds the path to the file where the class is defined. | |||
* | |||
* @param string $class The name of the class | |||
* | |||
* @return string|false The path if found, false otherwise | |||
*/ | |||
public function findFile($class) | |||
{ | |||
// work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 | |||
if ('\\' == $class[0]) { | |||
$class = substr($class, 1); | |||
} | |||
// class map lookup | |||
if (isset($this->classMap[$class])) { | |||
return $this->classMap[$class]; | |||
} | |||
if ($this->classMapAuthoritative) { | |||
return false; | |||
} | |||
$file = $this->findFileWithExtension($class, '.php'); | |||
// Search for Hack files if we are running on HHVM | |||
if ($file === null && defined('HHVM_VERSION')) { | |||
$file = $this->findFileWithExtension($class, '.hh'); | |||
} | |||
if ($file === null) { | |||
// Remember that this class does not exist. | |||
return $this->classMap[$class] = false; | |||
} | |||
return $file; | |||
} | |||
private function findFileWithExtension($class, $ext) | |||
{ | |||
// PSR-4 lookup | |||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; | |||
$first = $class[0]; | |||
if (isset($this->prefixLengthsPsr4[$first])) { | |||
foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { | |||
if (0 === strpos($class, $prefix)) { | |||
foreach ($this->prefixDirsPsr4[$prefix] as $dir) { | |||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { | |||
return $file; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
// PSR-4 fallback dirs | |||
foreach ($this->fallbackDirsPsr4 as $dir) { | |||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { | |||
return $file; | |||
} | |||
} | |||
// PSR-0 lookup | |||
if (false !== $pos = strrpos($class, '\\')) { | |||
// namespaced class name | |||
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) | |||
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); | |||
} else { | |||
// PEAR-like class name | |||
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; | |||
} | |||
if (isset($this->prefixesPsr0[$first])) { | |||
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { | |||
if (0 === strpos($class, $prefix)) { | |||
foreach ($dirs as $dir) { | |||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { | |||
return $file; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
// PSR-0 fallback dirs | |||
foreach ($this->fallbackDirsPsr0 as $dir) { | |||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { | |||
return $file; | |||
} | |||
} | |||
// PSR-0 include paths. | |||
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { | |||
return $file; | |||
} | |||
} | |||
} | |||
/** | |||
* Scope isolated include. | |||
* | |||
* Prevents access to $this/self from included files. | |||
*/ | |||
function includeFile($file) | |||
{ | |||
include $file; | |||
} |
@@ -0,0 +1,21 @@ | |||
Copyright (c) 2016 Nils Adermann, Jordi Boggiano | |||
Permission is hereby granted, free of charge, to any person obtaining a copy | |||
of this software and associated documentation files (the "Software"), to deal | |||
in the Software without restriction, including without limitation the rights | |||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |||
copies of the Software, and to permit persons to whom the Software is furnished | |||
to do so, subject to the following conditions: | |||
The above copyright notice and this permission notice shall be included in all | |||
copies or substantial portions of the Software. | |||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |||
THE SOFTWARE. | |||
@@ -0,0 +1,9 @@ | |||
<?php | |||
// autoload_classmap.php @generated by Composer | |||
$vendorDir = dirname(dirname(__FILE__)); | |||
$baseDir = dirname($vendorDir); | |||
return array( | |||
); |
@@ -0,0 +1,10 @@ | |||
<?php | |||
// autoload_files.php @generated by Composer | |||
$vendorDir = dirname(dirname(__FILE__)); | |||
$baseDir = dirname($vendorDir); | |||
return array( | |||
'c7359326b6707d98bdc176bf9ddeaebf' => $vendorDir . '/catfan/medoo/medoo.php', | |||
); |
@@ -0,0 +1,9 @@ | |||
<?php | |||
// autoload_namespaces.php @generated by Composer | |||
$vendorDir = dirname(dirname(__FILE__)); | |||
$baseDir = dirname($vendorDir); | |||
return array( | |||
); |
@@ -0,0 +1,9 @@ | |||
<?php | |||
// autoload_psr4.php @generated by Composer | |||
$vendorDir = dirname(dirname(__FILE__)); | |||
$baseDir = dirname($vendorDir); | |||
return array( | |||
); |
@@ -0,0 +1,70 @@ | |||
<?php | |||
// autoload_real.php @generated by Composer | |||
class ComposerAutoloaderInitced6a9042f97dd8b342a978ca0b1aac0 | |||
{ | |||
private static $loader; | |||
public static function loadClassLoader($class) | |||
{ | |||
if ('Composer\Autoload\ClassLoader' === $class) { | |||
require __DIR__ . '/ClassLoader.php'; | |||
} | |||
} | |||
public static function getLoader() | |||
{ | |||
if (null !== self::$loader) { | |||
return self::$loader; | |||
} | |||
spl_autoload_register(array('ComposerAutoloaderInitced6a9042f97dd8b342a978ca0b1aac0', 'loadClassLoader'), true, true); | |||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(); | |||
spl_autoload_unregister(array('ComposerAutoloaderInitced6a9042f97dd8b342a978ca0b1aac0', 'loadClassLoader')); | |||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION'); | |||
if ($useStaticLoader) { | |||
require_once __DIR__ . '/autoload_static.php'; | |||
call_user_func(\Composer\Autoload\ComposerStaticInitced6a9042f97dd8b342a978ca0b1aac0::getInitializer($loader)); | |||
} else { | |||
$map = require __DIR__ . '/autoload_namespaces.php'; | |||
foreach ($map as $namespace => $path) { | |||
$loader->set($namespace, $path); | |||
} | |||
$map = require __DIR__ . '/autoload_psr4.php'; | |||
foreach ($map as $namespace => $path) { | |||
$loader->setPsr4($namespace, $path); | |||
} | |||
$classMap = require __DIR__ . '/autoload_classmap.php'; | |||
if ($classMap) { | |||
$loader->addClassMap($classMap); | |||
} | |||
} | |||
$loader->register(true); | |||
if ($useStaticLoader) { | |||
$includeFiles = Composer\Autoload\ComposerStaticInitced6a9042f97dd8b342a978ca0b1aac0::$files; | |||
} else { | |||
$includeFiles = require __DIR__ . '/autoload_files.php'; | |||
} | |||
foreach ($includeFiles as $fileIdentifier => $file) { | |||
composerRequireced6a9042f97dd8b342a978ca0b1aac0($fileIdentifier, $file); | |||
} | |||
return $loader; | |||
} | |||
} | |||
function composerRequireced6a9042f97dd8b342a978ca0b1aac0($fileIdentifier, $file) | |||
{ | |||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { | |||
require $file; | |||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; | |||
} | |||
} |
@@ -0,0 +1,19 @@ | |||
<?php | |||
// autoload_static.php @generated by Composer | |||
namespace Composer\Autoload; | |||
class ComposerStaticInitced6a9042f97dd8b342a978ca0b1aac0 | |||
{ | |||
public static $files = array ( | |||
'c7359326b6707d98bdc176bf9ddeaebf' => __DIR__ . '/..' . '/catfan/medoo/medoo.php', | |||
); | |||
public static function getInitializer(ClassLoader $loader) | |||
{ | |||
return \Closure::bind(function () use ($loader) { | |||
}, null, ClassLoader::class); | |||
} | |||
} |
@@ -0,0 +1,59 @@ | |||
[ | |||
{ | |||
"name": "catfan/medoo", | |||
"version": "v1.1.3", | |||
"version_normalized": "1.1.3.0", | |||
"source": { | |||
"type": "git", | |||
"url": "https://github.com/catfan/Medoo.git", | |||
"reference": "2601ffd53971866695c544c955d580d3d36b3848" | |||
}, | |||
"dist": { | |||
"type": "zip", | |||
"url": "https://api.github.com/repos/catfan/Medoo/zipball/2601ffd53971866695c544c955d580d3d36b3848", | |||
"reference": "2601ffd53971866695c544c955d580d3d36b3848", | |||
"shasum": "" | |||
}, | |||
"require": { | |||
"ext-pdo": "*", | |||
"php": ">=5.1" | |||
}, | |||
"suggest": { | |||
"ext-pdo_dblib": "For MSSQL or Sybase databases on Linux/UNIX platform", | |||
"ext-pdo_mysql": "For MySQL or MariaDB databases", | |||
"ext-pdo_oci": "For Oracle databases", | |||
"ext-pdo_pqsql": "For PostgreSQL databases", | |||
"ext-pdo_sqlite": "For SQLite databases", | |||
"ext-pdo_sqlsrv": "For MSSQL databases on Windows platform" | |||
}, | |||
"time": "2016-09-05 07:18:35", | |||
"type": "framework", | |||
"installation-source": "dist", | |||
"autoload": { | |||
"files": [ | |||
"medoo.php" | |||
] | |||
}, | |||
"notification-url": "https://packagist.org/downloads/", | |||
"license": [ | |||
"MIT" | |||
], | |||
"authors": [ | |||
{ | |||
"name": "Angel Lai", | |||
"email": "angel@catfan.me" | |||
} | |||
], | |||
"description": "The Lightest PHP database framework to accelerate development", | |||
"homepage": "http://medoo.in", | |||
"keywords": [ | |||
"database", | |||
"lightweight", | |||
"mssql", | |||
"mysql", | |||
"php framework", | |||
"sql", | |||
"sqlite" | |||
] | |||
} | |||
] |