Commit a4aee415 authored by dmorley's avatar dmorley

fix spam loophole

parent 4a7a6f3f
language: php
php:
- 5.3
- 5.4
- 5.5
before_script: "./phpunit/before.sh"
script: export DISPLAY=:99.0 && phpunit
notifications:
irc: "irc.freenode.org#diasporg"
\ No newline at end of file
This diff is collapsed.
<?php
//Copyright (c) 2011, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file.
//this is just a single api for a pod for the android app to get data
include('config.php');
$dbh = pg_connect("dbname=$pgdb user=$pguser password=$pgpass");
if (!$dbh) {
die("Error in connection: " . pg_last_error());
}
$sql = "SELECT * FROM pods WHERE domain = $1";
$result = pg_query_params($dbh, $sql, array($_GET['url']));
if (!$result) {
die("Error in SQL query: " . pg_last_error());
}
while ($row = pg_fetch_array($result)) {
echo "Status: " . $row["status"] . "<br>";
echo "Last Git Pull: " . $row["hgitdate"] . "<br>";
echo "Uptime This Month " . $row["uptimelast7"] . "<br>";
echo "Months Monitored: " . $row["monthsmonitored"] . "<br>";
echo "Response Time: " . $row["responsetimelast7"] . "<br>";
echo "User Rating: ". $row["userrating"] . "<br>";
echo "Server Location: ". $row["country"] . "<br>";
echo "Latitude: ". $row["lat"] . "<br>";
echo "Longitude: ". $row["long"] . "<br>";
}
pg_free_result($result);
pg_close($dbh);
?>
db/api-more.php
\ No newline at end of file
......@@ -18,6 +18,10 @@ $domain = $_POST['domain'];
if (!$result) {
die("Error in SQL query: " . pg_last_error());
}
$rows = pg_num_rows($result);
if ($rows <= 0) {
echo "domain not found";die;
}
while ($row = pg_fetch_array($result)) {
if ($row["email"] <> $_POST['email']) {
echo "email not a match";die;
......
......@@ -27,7 +27,7 @@ Click column names to sort and find a pod.
Show as: <a href="?mapview=true">Map</a> | <a href="/">Simple Table</a> | <a href="?advancedview=true">Advanced Table</a>
<meta charset="utf-8">
<!-- /* Copyright (c) 2011, David Morley. This file is licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file. */ -->
<table id="myTable" class="tablesorter zebra-striped" width="750px">
<table id="myTable" class="tablesorter zebra-striped" style="width:750px; !important">
<thead>
<tr>
<th width="220px">Diaspora Pod<a class="tipsy" title="A pod is a site for you to set up your account.">?</a></th>
......
<?php
use Symfony\CS\FixerInterface;
$finder = Symfony\CS\Finder\DefaultFinder::create()
->notName('LICENSE')
->notName('README.md')
->notName('.php_cs')
->notName('composer.*')
->notName('phpunit.xml*')
->notName('*.phar')
->exclude('vendor')
->exclude('examples')
->exclude('Symfony/CS/Tests/Fixer')
->notName('ElseifFixer.php')
->exclude('data')
->in(__DIR__)
;
return Symfony\CS\Config\Config::create()
->finder($finder)
;
language: php
php:
- "5.2"
branches:
only:
- devel
script:
- phpunit --configuration tests/phpunit.xml --coverage-text
notifications:
email: false
MIT License
Copyright (c) <2011-2013> <Serban Ghita> <serbanghita@gmail.com>
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.
Developer’s Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
This diff is collapsed.
This diff is collapsed.
{
"name": "mobiledetect/mobiledetectlib",
"type": "library",
"description": "Mobile_Detect is a lightweight PHP class for detecting mobile devices. It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.",
"keywords": ["mobile", "mobile detect", "mobile detector", "php mobile detect", "detect mobile devices"],
"homepage": "https://github.com/serbanghita/Mobile-Detect",
"license": "MIT",
"authors": [
{
"name": "Serban Ghita",
"email": "serbanghita@gmail.com",
"homepage": "http://mobiledetect.net",
"role": "Developer"
}
],
"require": {
"php": ">=5.0.0"
},
"require-dev": {
"phpunit/phpunit": "*"
},
"autoload": {
"classmap": ["Mobile_Detect.php"],
"psr-0": {
"Detection": "namespaced/"
}
}
}
This diff is collapsed.
This diff is collapsed.
<?php
/**
* MIT License
* ===========
*
* 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.
*
* -----------------------------------------------------------------------
*
*
* Run this in your browser to see the example!
*
*
*
* IMPORTANT: Clear your sessions/cookies before running UA tests.
*
* This is a procedural approach example of how to switch your website layout
* based on a variable $layoutType.
*
* The example also includes the switch links that you can put in the footer
* of your page. Is a good practice to let the user switch between layouts,
* even if he is visiting the page from a phone or tablet.
* ------------------------------------------------------------------------
*
* @author Serban Ghita <serbanghita@gmail.com>
* @license MIT License https://github.com/serbanghita/Mobile-Detect/blob/master/LICENSE.txt
*
*/
// This is mandatory if you're using sessions.
session_start();
// It's mandatory to include the library.
require_once '../Mobile_Detect.php';
/**
* Begin helper functions.
*/
// Your default site layouts.
// Update this array if you have fewer layout types.
function layoutTypes()
{
return array('classic', 'mobile', 'tablet');
}
function initLayoutType()
{
// Safety check.
if (!class_exists('Mobile_Detect')) { return 'classic'; }
$detect = new Mobile_Detect;
$isMobile = $detect->isMobile();
$isTablet = $detect->isTablet();
$layoutTypes = layoutTypes();
// Set the layout type.
if ( isset($_GET['layoutType']) ) {
$layoutType = $_GET['layoutType'];
} else {
if (empty($_SESSION['layoutType'])) {
$layoutType = ($isMobile ? ($isTablet ? 'tablet' : 'mobile') : 'classic');
} else {
$layoutType = $_SESSION['layoutType'];
}
}
// Fallback. If everything fails choose classic layout.
if ( !in_array($layoutType, $layoutTypes) ) { $layoutType = 'classic'; }
// Store the layout type for future use.
$_SESSION['layoutType'] = $layoutType;
return $layoutType;
}
/**
* End helper functions.
*/
// Let's roll. Call this function!
$layoutType = initLayoutType();
/**
*
* Example of layout switch links.
* Eg. ['Classic' | Mobile | 'Tablet']
*
*/
?>
<?php if(!isset($_GET['page'])): ?>
<!-- example page #1 -->
<h1>Demo page number one.</h1>
<p>You can go to page <a href="<?php echo $_SERVER['PHP_SELF']; ?>?page=two">two</a>.</p>
<p>Showing you the <b><?php echo $layoutType; ?></b> version.</p>
<p><b>Note:</b> When running this test using the same browser with multiple User-Agents, clear your cookies/session before each test.</p>
<?php endif; ?>
<?php if(isset($_GET['page']) && $_GET['page']=='two'): ?>
<!-- example page #2 -->
<h1>Demo page number two.</h1>
<p>You can go back to page <a href="<?php echo $_SERVER['PHP_SELF']; ?>">one</a>.</p>
<p>Showing you the <b><?php echo $layoutType; ?></b> version.</p>
<?php endif; ?>
<!-- Footer links example. Change this as you like. -->
<?php foreach(layoutTypes() as $_layoutType): ?>
<?php if($_layoutType == $layoutType): ?>
<?php echo strtoupper($_layoutType); ?>
<?php else: ?>
<a href="<?php echo $_SERVER['PHP_SELF']; ?>?layoutType=<?php echo $_layoutType; ?>"><?php echo strtoupper($_layoutType); ?></a>
<?php endif; ?>
<?php endforeach;
<?php
/**
* Little piece of PHP to make Mobile_Detect auto-loadable in PSR-0 compatible PHP autoloaders like
* the Symfony Universal ClassLoader by Fabien Potencier. Since PSR-0 handles an underscore in
* classnames (on the filesystem) as a slash, "Mobile_Detect.php" autoloaders will try to convert
* the classname and path to "Mobile\Detect.php". This script will ensure autoloading with:
* - Namespace: Detection
* - Classname: MobileDetect
* - Namespased: \Detection\MobileDetect
* - Autoload path: ./namespaced
* - Converted path: ./namespaced/Detection/MobileDetect.php
*
* Don't forget to use MobileDetect (instead of Mobile_Detect) as class in code when autoloading.
*
* Thanks to @WietseWind.
* For details please check: https://github.com/serbanghita/Mobile-Detect/pull/120
*/
namespace Detection;
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Mobile_Detect.php';
class MobileDetect extends \Mobile_Detect {}
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
<?php
/**
* MIT License
* ===========
*
* 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.
*
*
* @author Serban Ghita <serbanghita@gmail.com>
* @license MIT License https://github.com/serbanghita/Mobile-Detect/blob/master/LICENSE.txt
* @link http://mobiledetect.net
*/
class UserAgentTest extends PHPUnit_Framework_TestCase
{
protected static $ualist = array();
protected static $json;
public static function generateJson()
{
//in case this gets run multiple times
if (isset(self::$json)) {
return self::$json;
}
//the json and PHP formatted files
$jsonFile = dirname(__FILE__) . '/ualist.json';
$phpFile = dirname(__FILE__) . '/UA_List.inc.php';
//check recency of the file
if (file_exists($jsonFile) && is_readable($jsonFile)) {
//read the json file
$json = json_decode(file_get_contents($jsonFile), true);
//check that the hash matches
$hash = isset($json['hash']) ? $json['hash'] : null;
if ($hash == sha1_file($phpFile)) {
//file is up to date, just read the json file
self::$json = $json['user_agents'];
return self::$json;
}
}
//uses the UA_List.inc.php to generate a json file
if (file_exists($jsonFile) && !is_writable($jsonFile)) {
throw new RuntimeException("Need to be able to create/update $jsonFile from UA_List.inc.php.");
}
if (!is_writable(dirname($jsonFile))) {
throw new RuntimeException("Insufficient permissions to create this file: $jsonFile");
}
//currently stored as a PHP array
$list = include $phpFile;
$json = array();
foreach ($list as $vendor => $vendorList) {
foreach ($vendorList as $userAgent => $props) {
if (is_int($userAgent)) {
//this means that the user agent is the props
$userAgent = $props;
$props = array();
}
$tmp = array(
'vendor' => $vendor,
'user_agent' => $userAgent
);
if (isset($props['isMobile'])) {
$tmp['mobile'] = $props['isMobile'];
}
if (isset($props['isTablet'])) {
$tmp['tablet'] = $props['isTablet'];
}
if (isset($props['version'])) {
$tmp['version'] = $props['version'];
}
if (isset($props['model'])) {
$tmp['model'] = $props['model'];
}
$json[] = $tmp;
}
}
//save the hash
$hash = sha1_file($phpFile);
$json = array(
'hash' => $hash,
'user_agents' => $json
);
if (defined('JSON_PRETTY_PRINT')) {
$jsonString = json_encode($json, JSON_PRETTY_PRINT);
} else {
$jsonString = json_encode($json);
}
file_put_contents($jsonFile, $jsonString);
self::$json = $json['user_agents'];
return self::$json;
}
public static function setUpBeforeClass()
{
//generate json file first
self::generateJson();
//get the generated JSON data
$json = self::$json;
//make a list that is usable by functions (THE ORDER OF THE KEYS MATTERS!)
foreach ($json as $userAgent) {
$tmp = array();
$tmp[] = isset($userAgent['user_agent']) ? $userAgent['user_agent'] : null;
$tmp[] = isset($userAgent['mobile']) ? $userAgent['mobile'] : null;
$tmp[] = isset($userAgent['tablet']) ? $userAgent['tablet'] : null;
$tmp[] = isset($userAgent['version']) ? $userAgent['version'] : null;
$tmp[] = isset($userAgent['model']) ? $userAgent['model'] : null;
$tmp[] = isset($userAgent['vendor']) ? $userAgent['vendor'] : null;
self::$ualist[] = $tmp;
}
}
public function userAgentData()
{
if (!count(self::$ualist))
self::setUpBeforeClass();
return self::$ualist;
}
/**
* @dataProvider userAgentData
*/
public function testUserAgents($userAgent, $isMobile, $isTablet, $version, $model, $vendor)
{
//make sure we're passed valid data
if (!is_string($userAgent) || !is_bool($isMobile) || !is_bool($isTablet)) {
$this->markTestIncomplete("The User-Agent $userAgent does not have sufficient information for testing.");
return;
}
//setup
$md = new Mobile_Detect;
$md->setUserAgent($userAgent);
//is mobile?
$this->assertEquals($md->isMobile(), $isMobile);
//is tablet?
$this->assertEquals($md->isTablet(), $isTablet);
if (isset($version)) {
foreach ($version as $condition => $assertion) {
$this->assertEquals($assertion, $md->version($condition), 'FAILED UA (version("'.$condition.'")): '.$userAgent);
}
}
//version property tests
if (isset($version)) {
foreach ($version as $property => $stringVersion) {
$v = $md->version($property);
$this->assertSame($stringVersion, $v);
}
}
//@todo: model test, not sure how exactly yet
//@todo: vendor test. The below is theoretical, but fails 50% of the tests...
/*if (isset($vendor)) {
$method = "is$vendor";
$this->assertTrue($md->{$method}(), "Expected Mobile_Detect::{$method}() to be true.");
}*/
}
}
<?php
/**
* MIT License
* ===========
*
* 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.
*
*
* @author Serban Ghita <serbanghita@gmail.com>
* @license MIT License https://github.com/serbanghita/Mobile-Detect/blob/master/LICENSE.txt
* @link http://mobiledetect.net
*/
class VendorsTest extends PHPUnit_Framework_TestCase
{
protected $detect;
protected static $items;
public function setUp()
{
$this->detect = new Mobile_Detect;
}
public static function setUpBeforeClass()
{
//this method could be called multiple times
if (!self::$items) {
self::$items = include dirname(__FILE__).'/UA_List.inc.php';
}
}
public function testisMobileIsTablet()
{
foreach (self::$items as $brand => $deviceArr) {
foreach ($deviceArr as $userAgent => $conditions) {
if (!is_array($conditions)) { continue; }
$this->detect->setUserAgent($userAgent);
foreach ($conditions as $condition => $assert) {