Commit a86681bb authored by Stuart McCulloch Anderson's avatar Stuart McCulloch Anderson

Merge branch 'develop' into 'master'

Develop

Closes #189, #186, #187, #58, #51, and #184

See merge request !33
parents 53b132e8 c1b2d021
Pipeline #101 passed with stages
in 2 minutes and 4 seconds
......@@ -26,3 +26,7 @@ vendor
/dev/git-bump-version/
/dev/phpunit.phar
/dev/composer.phar
/dev/.lastChangeLog
/binaries/
/nxfitbit.iml
/ux/sites.json
......@@ -12,12 +12,11 @@ cache:
- vendor/
- binaries/
before_script:
- bash ./dev/build_dev_env.sh
# Run our tests
test:php:
stage: test
before_script:
- bash ./dev/build_dev_env.sh
script:
- php ./binaries/phpunit.phar -c phpunit.xml
- ./vendor/bin/parallel-lint --exclude library --exclude vendor --exclude binaries/php-docblock-checker-1.3.4 --exclude binaries/phpspec --blame -e php .
......@@ -26,25 +25,27 @@ test:php:
# Run our tests
test:phpcs:
stage: syntax
before_script:
- bash ./dev/build_dev_env.sh
script:
- bash ./dev/phpcs_cbf.sh
# Run our tests
test:phploc:
stage: info
before_script:
- bash ./dev/build_dev_env.sh
script:
- ./binaries/php-docblock-checker-1.3.4/vendor/bin/phploc inc
- ./binaries/php-docblock-checker-1.3.4/vendor/bin/phploc lib
deploy_review:
stage: review
script:
- echo "Deploy a review app"
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- ssh nxad@nxfifteen.me.uk /home/nxad/homes/gitrepos/deploy_review
- /home/nxad/gits/deploy_review "$REVIEW_PATH" $CI_COMMIT_REF_NAME $CI_ENVIRONMENT_SLUG
environment:
name: review/$CI_COMMIT_REF_NAME
url: https://$CI_ENVIRONMENT_SLUG.itsabeta.nx
url: http://docs.core.itsabeta.nx/
only:
- branches
except:
......@@ -54,17 +55,24 @@ deploy_staging:
stage: stage
script:
- echo "Deploy to staging server"
- /home/nxad/gits/deploy_staging "$STAGING_PATH/$CI_ENVIRONMENT_SLUG" $CI_COMMIT_REF_NAME $CI_ENVIRONMENT_SLUG
environment:
name: staging
url: https://staging.example.com
url: http://core.itsabeta.nx/$CI_ENVIRONMENT_SLUG/ux/
when: manual
only:
- master
- branches
except:
- master
deploy_prod:
stage: deploy
script:
- echo "Deploy to production server"
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- scp ./dev/deploy_prod nxad@nxfifteen.me.uk:/home/nxad/homes/gitrepos/deploy_prod
- ssh nxad@nxfifteen.me.uk /home/nxad/homes/gitrepos/deploy_prod
environment:
name: production
url: https://nxfifteen.me.uk/api/fitbit/
......
<?php
require_once(dirname(__FILE__) . "/lib/autoloader.php");
use Core\Core;
define('IS_CRON_RUN', true);
......@@ -14,18 +16,13 @@
* @license http://stuart.nx15.at/mit/2015 MIT
*/
if (!function_exists("nxr")) {
require_once(dirname(__FILE__) . "/inc/functions.php");
}
require_once(dirname(__FILE__) . "/inc/Core.php");
$fitbitApp = new Core();
$end = time() + 20;
$repopulate_queue = run_through_queue();
if ($repopulate_queue) {
nxr("Ready to repopulate the queue");
nxr(0, "Ready to repopulate the queue");
$unfinishedUsers = $fitbitApp->getDatabase()->query("-- noinspection SqlDialectInspection
SELECT fuid, name from " . $fitbitApp->getSetting("db_prefix", null, false) . "users where
......@@ -42,10 +39,10 @@
) {
foreach ($unfinishedUsers as $user) {
if (!$fitbitApp->valdidateOAuth($fitbitApp->getUserOAuthTokens($user['fuid'], false))) {
nxr($user['name'] . " has not completed the OAuth configuration");
nxr(0, $user['name'] . " has not completed the OAuth configuration");
} else {
if (time() < $end) {
nxr("Adding all to Q for " . $user['name']);
nxr(0, "Adding all to Q for " . $user['name']);
$fitbitApp->addCronJob($user['fuid'], 'all');
}
}
......@@ -62,7 +59,7 @@
}
if (count($allowed_triggers) == 0) {
nxr("I am not allowed to re-queue anything so will re-queue with empty records");
nxr(0, "I am not allowed to re-queue anything so will re-queue with empty records");
} else {
$unfinishedUsers = $fitbitApp->getDatabase()->query("-- noinspection SqlDialectInspection
SELECT fuid, name from " . $fitbitApp->getSetting("db_prefix", null,
......@@ -75,25 +72,25 @@
if (!empty($unfinishedUsers) and count($unfinishedUsers) > 0) {
foreach ($unfinishedUsers as $user) {
if (!$fitbitApp->valdidateOAuth($fitbitApp->getUserOAuthTokens($user['fuid'], false))) {
nxr($user['name'] . " has not completed the OAuth configuration");
nxr(0, $user['name'] . " has not completed the OAuth configuration");
} else {
nxr(" Repopulating for " . $user['name']);
nxr(1, " Repopulating for " . $user['name']);
$fitbitApp->getFitbitAPI($user['fuid'])->setActiveUser($user['fuid']);
foreach ($allowed_triggers as $allowed_trigger) {
if (!is_numeric($fitbitApp->getFitbitAPI()->isAllowed($allowed_trigger, true))) {
if ($fitbitApp->getFitbitAPI($user['fuid'])->isTriggerCooled($allowed_trigger)) {
nxr(" + $allowed_trigger added to queue");
nxr(1, " + $allowed_trigger added to queue");
$fitbitApp->addCronJob($user['fuid'], $allowed_trigger);
} else {
nxr(" - $allowed_trigger still too hot");
nxr(1, " - $allowed_trigger still too hot");
}
}
}
}
}
} else {
nxr("There is nothing to queue");
nxr(0, "There is nothing to queue");
}
}
......@@ -118,7 +115,7 @@
$cooldown = $fitbitApp->getUserCooldown($job['user']);
if ($fitbitApp->getSetting('scope_' . $job['trigger'], true)) { //TODO: Set top false by default
if (strtotime($cooldown) < strtotime(date("Y-m-d H:i:s"))) {
nxr("Processing queue item " . $fitbitApp->supportedApi($job['trigger']) . " for " . $job['user']);
nxr(0, "Processing queue item " . $fitbitApp->supportedApi($job['trigger']) . " for " . $job['user']);
$jobRun = $fitbitApp->getFitbitAPI($job['user'], true)->pull($job['user'],
$job['trigger']);
if ($fitbitApp->getFitbitAPI($job['user'])->isApiError($jobRun)) {
......@@ -131,7 +128,7 @@
'core_version' => $fitbitApp->getSetting("version", "0.0.0.1", true)
)
));
nxr("* Cron Error: " . $fitbitApp->lookupErrorCode($jobRun));
nxr(0, "* Cron Error: " . $fitbitApp->lookupErrorCode($jobRun));
} else {
$fitbitApp->delCronJob($job['user'], $job['trigger']);
}
......@@ -147,11 +144,11 @@
'core_version' => $fitbitApp->getSetting("version", "0.0.0.1", true)
)
));
nxr("Can not process " . $fitbitApp->supportedApi($job['trigger']) . ". API limit reached for " . $job['user'] . ". Cooldown period ends " . $cooldown);
nxr(0, "Can not process " . $fitbitApp->supportedApi($job['trigger']) . ". API limit reached for " . $job['user'] . ". Cooldown period ends " . $cooldown);
$fitbitApp->delCronJob($job['user'], $job['trigger']);
}
} else {
nxr(" " . $fitbitApp->supportedApi($job['trigger']) . " has been disabled");
nxr(1, $fitbitApp->supportedApi($job['trigger']) . " has been disabled");
$fitbitApp->delCronJob($job['user'], $job['trigger']);
}
......@@ -173,11 +170,11 @@
'core_version' => $fitbitApp->getSetting("version", "0.0.0.1", true)
)
));
nxr(" Can not process " . $fitbitApp->supportedApi($job['trigger']) . " since " . $job['user'] . " is no longer a user.");
nxr(2, "Can not process " . $fitbitApp->supportedApi($job['trigger']) . " since " . $job['user'] . " is no longer a user.");
$fitbitApp->delCronJob($job['user'], $job['trigger']);
}
} else {
nxr("Timeout reached skipping " . $fitbitApp->supportedApi($job['trigger']) . " for " . $job['user']);
nxr(0, "Timeout reached skipping " . $fitbitApp->supportedApi($job['trigger']) . " for " . $job['user']);
$repopulate_queue = false;
}
}
......
#!/bin/bash
CI_COMMIT_REF_NAME="$1"
CI_ENVIRONMENT_SLUG="$2"
eval $(ssh-agent -s)
ssh-add /home/nxad/.ssh/id_rsa_deploy
if [ -d "/home/nxad/public_html/api/fitbit" ]; then
cd "/home/nxad/public_html/api/fitbit"
git checkout .
git checkout master
git pull
/home/nxad/bin/composer update --no-dev
php5 ./get.php --user=269VLG --get=nomie_trackers
fi
#!/bin/bash
ROOTPATH="$1"
CI_COMMIT_REF_NAME="$2"
CI_ENVIRONMENT_SLUG="$3"
eval $(ssh-agent -s)
ssh-add /home/nxad/.ssh/id_rsa_pss
if [ ! -d "$ROOTPATH" ]; then
mkdir "$ROOTPATH"
cd "$ROOTPATH"
git clone git@nxfifteen.me.uk:nx-fitness/nxfitness-core.git ./
else
cd "$ROOTPATH"
fi
cd "$ROOTPATH"
git checkout develop
git pull
if [ ! -d "$ROOTPATH/binaries" ]; then
echo "***creating binaries"
mkdir "$ROOTPATH/binaries"
fi
if [ ! -f "composer.phar" ]; then
echo "***downloading composer"
cd "$ROOTPATH/binaries"
curl -sS https://getcomposer.org/installer | php >/dev/null 2>&1
cd "$ROOTPATH"
echo "***running composer install dev"
php "$ROOTPATH/binaries/composer.phar" install --dev >/dev/null 2>&1
else
echo "***running composer update dev"
php "$ROOTPATH/binaries/composer.phar" update --dev >/dev/null 2>&1
fi
cd "$ROOTPATH"
php "$ROOTPATH/vendor/phpdocumentor/phpdocumentor/bin/phpdoc" >/dev/null 2>&1
rsync -vhru --delete-after ./docs/development/* /var/www/dev/development/
#!/bin/bash
ROOTPATH="$1"
CI_COMMIT_REF_NAME="$2"
CI_ENVIRONMENT_SLUG="$3"
eval $(ssh-agent -s)
ssh-add /home/nxad/.ssh/id_rsa_pss
if [ ! -d "$ROOTPATH" ]; then
mkdir -p "$ROOTPATH"
cd "$ROOTPATH"
git clone git@nxfifteen.me.uk:nx-fitness/nxfitness-core.git ./
else
cd "$ROOTPATH"
fi
cd "$ROOTPATH"
git checkout develop
git pull
if [ ! -d "$ROOTPATH/binaries" ]; then
echo "creating binaries"
mkdir "$ROOTPATH/binaries"
fi
if [ ! -f "composer.phar" ]; then
echo "downloading composer"
cd "$ROOTPATH/binaries"
curl -sS https://getcomposer.org/installer | php >/dev/null 2>&1
cd "$ROOTPATH"
fi
echo "running composer install dev"
php "$ROOTPATH/binaries/composer.phar" install --dev >/dev/null 2>&1
#bash "$ROOTPATH/dev/genPHPDocs" "$ROOTPATH"
#bash "$ROOTPATH/dev/genDocs" "$ROOTPATH"
#!/bin/bash
ROOTPATH="$1"
if [ ! -d "$ROOTPATH/binaries" ]; then
echo "creating binaries"
mkdir "$ROOTPATH/binaries"
fi
if [ ! -f "$ROOTPATH/binaries/composer.phar" ]; then
echo "downloading composer"
cd "$ROOTPATH/binaries"
curl -sS https://getcomposer.org/installer | php #>/dev/null 2>&1
cd "$ROOTPATH"
fi
echo "running composer install dev"
php "$ROOTPATH/binaries/composer.phar" install --dev #>/dev/null 2>&1
FROMTAG=""
CURRENTCOMIT=`git rev-parse --verify HEAD`
if [ -f "$ROOTPATH/dev/.lastChangeLog" ]; then
LASTCOMMIT=`cat "$ROOTPATH/dev/.lastChangeLog"`
if [ "$LASTCOMMIT" != "$CURRENTCOMIT" ]; then
FROMTAG="--tag $LASTCOMMIT"
fi
fi
/home/nxad/gits/git-changelog/tasks/command.js -p gitlab --file "$ROOTPATH/docs/wiki.core/change-log.md" $FROMTAG;
/home/nxad/gits/git-changelog/tasks/command.js -p gitlab --file "$ROOTPATH/docs/wiki.core/extended-change-log.md" --extended;
cd "$ROOTPATH/docs/wiki.core"
git add change-log.md extended-change-log.md
git commit -m "chore(changelog): Updated changelog files"
git push
#!/bin/bash
ROOTPATH="$1"
eval $(ssh-agent -s)
ssh-add /home/nxad/.ssh/id_rsa_pss
php "$ROOTPATH/vendor/phpdocumentor/phpdocumentor/bin/phpdoc" >/dev/null 2>&1
cd "$ROOTPATH/docs/wiki.core"
rsync -vhru --delete-after ./ /var/www/dev/development/
#FROMTAG=""
#CURRENTCOMIT=`git rev-parse --verify HEAD`
#if [ -f "$ROOTPATH/dev/.lastChangeLog" ]; then
# LASTCOMMIT=`cat "$ROOTPATH/dev/.lastChangeLog"`
#
# if [ "$LASTCOMMIT" != "$CURRENTCOMIT" ]; then
# FROMTAG="--tag $LASTCOMMIT"
# fi
#fi
#if [ ! -d "$ROOTPATH/binaries/phpdoc-md" ]; then
# echo "cloning phpdoc-md"
# cd "$ROOTPATH/binaries"
# git clone git@nxfifteen.me.uk:nx-style/phpdoc-md.git >/dev/null 2>&1
# cd "$ROOTPATH/binaries/phpdoc-md"
# php "$ROOTPATH/binaries/composer.phar" install >/dev/null 2>&1
# cd "$ROOTPATH"
#else
# echo "updating phpdoc-md"
# cd "$ROOTPATH/binaries/phpdoc-md"
# git pull >/dev/null 2>&1
# cd "$ROOTPATH"
#fi
#
#if [ ! -d "$ROOTPATH/docs/wiki.core" ]; then
# echo "creating markdown"
# cd "$ROOTPATH/docs/"
# git clone git@nxfifteen.me.uk:nx-fitness/nxfitness-core.wiki.git ./wiki.core >/dev/null 2>&1
# cd "$ROOTPATH"
#else
# echo "updating markdown"
# cd "$ROOTPATH/docs/wiki.core"
# pwd
# git pull >/dev/null 2>&1
# cd "$ROOTPATH"
#fi
#
#php "$ROOTPATH/binaries/phpdoc-md/bin/phpdocmd" "$ROOTPATH/docs/development/structure.xml" "$ROOTPATH/docs/wiki.core/phpdoc/class"
#
#cd "$ROOTPATH/docs/wiki.core"
#
#
#/home/nxad/gits/git-changelog/tasks/command.js -p gitlab --file "$ROOTPATH/docs/wiki.core/change-log.md" $FROMTAG;
#/home/nxad/gits/git-changelog/tasks/command.js -p gitlab --file "$ROOTPATH/docs/wiki.core/extended-change-log.md" --extended;
#git add change-log.md extended-change-log.md
#git commit -m "chore(changelog): Updated changelog files"
#
#git add .
#git commit -m "chore(wiki): Updated phpdoc"
#
#ssh-add -D
#ssh-add /home/nxad/.ssh/id_rsa_wiki
#
#git push
<?php
require_once(dirname(__FILE__) . "/lib/autoloader.php");
/**
* Core - Cron commandline tool
*
......@@ -18,18 +20,17 @@
$_GET[$key] = $value;
}
require_once(dirname(__FILE__) . "/inc/Core.php");
$fitbitApp = new Core();
if ($fitbitApp->isUser($_GET['user'])) {
$cooldown = $fitbitApp->getUserCooldown($_GET['user']);
if (strtotime($cooldown) < strtotime(date("Y-m-d H:i:s"))) {
if ($fitbitApp->supportedApi($_GET['get']) != $_GET['get']) {
nxr("Forcing pull of " . $fitbitApp->supportedApi($_GET['get']) . " for " . $_GET['user']);
nxr(0, "Forcing pull of " . $fitbitApp->supportedApi($_GET['get']) . " for " . $_GET['user']);
$fitbitApp->getFitbitAPI($_GET['user'])->setForceSync(true);
$fitbitApp->getFitbitAPI($_GET['user'])->pull($_GET['user'], $_GET['get']);
} else {
nxr("Unknown trigger " . $_GET['get'] . ". Supported calls are:");
nxr(0, "Unknown trigger " . $_GET['get'] . ". Supported calls are:");
print_r($fitbitApp->supportedApi());
}
} else {
......@@ -43,7 +44,7 @@
'core_version' => $this->getAppClass()->getSetting("version", "0.0.0.1", true)
)
));
nxr("Can not process " . $fitbitApp->supportedApi($_GET['get']) . ". API limit reached for " . $_GET['user'] . ". Cooldown period ends " . $cooldown);
nxr(0, "Can not process " . $fitbitApp->supportedApi($_GET['get']) . ". API limit reached for " . $_GET['user'] . ". Cooldown period ends " . $cooldown);
}
} else {
$fitbitApp->getErrorRecording()->captureMessage("Unknown User", array('authentication'), array(
......@@ -55,5 +56,5 @@
'core_version' => $this->getAppClass()->getSetting("version", "0.0.0.1", true)
)
));
nxr("Can not process " . $fitbitApp->supportedApi($_GET['get']) . " since " . $_GET['user'] . " is no longer a user.");
nxr(0, "Can not process " . $fitbitApp->supportedApi($_GET['get']) . " since " . $_GET['user'] . " is no longer a user.");
}
<?php
require_once(dirname(__FILE__) . "/lib/autoloader.php");
use Core\Core;
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT');
......@@ -13,31 +16,6 @@
exit();
}
if (!function_exists("nxr_destroy_session")) {
function nxr_destroy_session()
{
// Unset all of the session variables.
$_SESSION = array();
// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}
// Finally, destroy the session.
session_destroy();
}
}
if (!function_exists("nxr")) {
require_once(dirname(__FILE__) . "/inc/functions.php");
}
if (!defined('DEBUG_MY_PROJECT')) {
define('DEBUG_MY_PROJECT', false);
}
......@@ -68,9 +46,9 @@
}
$sysPath = str_ireplace($_SESSION['core_config']['url'], "", $_SESSION['core_config']['http/']);
nxr("inputURL: " . $inputURL);
nxr("sysPath: " . $sysPath);
//nxr("sysPath: " . $_SERVER['']);
nxr(0, "inputURL: " . $inputURL);
nxr(0, "sysPath: " . $sysPath);
//nxr(0, "sysPath: " . $_SERVER['']);
if ($sysPath != "/") {
$inputURL = str_replace($sysPath, "", $inputURL);
......@@ -82,14 +60,13 @@
$inputURL = explode("/", $inputURL);
$url_namespace = $inputURL[0];
nxr("Namespace Called: " . $url_namespace);
nxr(0, "Namespace Called: " . $url_namespace);
if ($url_namespace == "register" && !array_key_exists("_nx_fb_usr", $_COOKIE)) {
// Authorise a user against Fitbit's OAuth AIP
nxr("New user registration started");
nxr(0, "New user registration started");
// Setup the App
require_once(dirname(__FILE__) . "/inc/Core.php");
$NxFitbit = new Core();
// Sent the user off too Fitbit to authenticate
......@@ -132,7 +109,6 @@
}
// Setup the App
require_once(dirname(__FILE__) . "/inc/Core.php");
$NxFitbit = new Core();
// We're even talking about a valid user right?
......@@ -202,7 +178,6 @@
} else {
try {
// Setup the App
require_once(dirname(__FILE__) . "/inc/Core.php");
$NxFitbit = new Core();
// Sent the user off too Fitbit to authenticate
......@@ -228,7 +203,7 @@
// Check again that this really is one of our users
if ($NxFitbit->isUser($resourceOwner->getId())) {
nxr("User OAuth credentials installed");
nxr(0, "User OAuth credentials installed");
// Update the users new keys
$NxFitbit->setUserOAuthTokens($resourceOwner->getId(), $accessToken);
......@@ -238,7 +213,7 @@
exit();
} else {
nxr(" OAuth return for new user: " . $resourceOwner->getId());
nxr(1, "OAuth return for new user: " . $resourceOwner->getId());
$pre_auth = $NxFitbit->getSetting("owners_friends");
$pre_auth = explode(",", $pre_auth);
......@@ -250,11 +225,11 @@
$newUserProfile = $NxFitbit->getFitbitAPI($newUserName)->pullBabel('user/-/profile.json', true);
if ($NxFitbit->getFitbitAPI($newUserName)->createNewUser($newUserProfile->user)) {
nxr(" User sent to new password screen");
nxr(2, "User sent to new password screen");
header("Location: " . $_SESSION['core_config']['http/admin'] . "/views/pages/register.php?usr=" . $newUserName);
}
} else {
nxr(" Non Friend registration: " . $resourceOwner->getId());
nxr(2, "Non Friend registration: " . $resourceOwner->getId());
header("Location: " . $_SESSION['core_config']['http/admin'] . "/?err=500");
}
......@@ -275,7 +250,7 @@
}
} else if ($url_namespace == "webhook" || $url_namespace == "service") {
nxr("Namespace Called: " . $url_namespace);
nxr(0, "Namespace Called: " . $url_namespace);
if (is_array($_GET) && array_key_exists("verify", $_GET)) {
$config = array();
......@@ -288,14 +263,14 @@
header('Content-type: text/plain');
header('HTTP/1.0 204 No Content');
nxr("Valid subscriber request - " . $url_namespace);
nxr(0, "Valid subscriber request - " . $url_namespace);
} else {
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('HTTP/1.0 404 Not Found');
nxr("Invalid subscriber request - '" . $_GET['verify'] . "' - " . $url_namespace);
nxr(print_r($config['api_subValidity'], true));
nxr(0, "Invalid subscriber request - '" . $_GET['verify'] . "' - " . $url_namespace);
nxr(0, print_r($config['api_subValidity'], true));
}
} else {
......@@ -309,7 +284,7 @@
header('HTTP/1.0 404 Not Found');
// If we're debugging things print out the unknown namespace
nxr("Namespace Called: " . $url_namespace);
nxr(0, "Namespace Called: " . $url_namespace);
} else {
// When we don't know what to do put the user over to the user interface screens
......
<?php
require_once(dirname(__FILE__) . "/lib/autoloader.php");
use Core\DataReturn;
use Core\RewardsMinecraft;
use Core\Rewards\RewardsMinecraft;
header('Access-Control-Allow-Origin: https://wp.dev.psi.nxfifteen.me.uk');
header('Cache-Control: no-cache, must-revalidate');
......@@ -102,7 +105,6 @@
} else if (array_key_exists("wmc_key", $_GET)) {
$start = microtime(true);
require_once(dirname(__FILE__) . "/inc/RewardsMinecraft.php");
$RewardsMinecraft = new RewardsMinecraft();
$json = $RewardsMinecraft->queryRewards();
......@@ -127,7 +129,6 @@
*/
function query_api()
{
require_once(dirname(__FILE__) . "/inc/DataReturn.php");
$dataReturnClass = new DataReturn($_GET['user']);
if ($dataReturnClass->isUser()) {
$json = $dataReturnClass->returnUserRecords($_GET);
......
<?php
namespace Core;
namespace Core\Analytics;
require_once(dirname(__FILE__) . "/../../autoloader.php");
use Core\Core;
use Exception;
use Medoo\Medoo;
use Raven_Autoloader;
use Raven_Client;
use Raven_ErrorHandler;
......@@ -37,7 +41,6 @@
public function __construct($appClass)
{
if (defined('SENTRY_DSN')) {
require_once(dirname(__FILE__) . "/../library/sentry/lib/Raven/Autoloader.php");
Raven_Autoloader::register();
$this->appClass = $appClass;
......@@ -103,7 +106,7 @@
{
if (defined('SENTRY_DSN')) {
$this->getSentryClient()->captureException($exception, $data, $logger, $vars);
nxr("### Exception Recorded ###");
nxr(0, "### Exception Recorded ###");
}
}
......@@ -118,16 +121,15 @@
*/
public function captureMessage($message, $params = array(), $data = array(), $stack = false, $vars = null)
{
nxr("[ERROR] $message");
nxr(0, "[ERROR] $message");
if (defined('SENTRY_DSN')) {
$this->getSentryClient()->captureMessage($message, $params, $data, $stack, $vars);
nxr("### Message Recorded ###");
nxr(0, "### Message Recorded ###");
}
}
/** @noinspection PhpUndefinedClassInspection */
/**
* @param \medoo $medoo
* @param Medoo $medoo
* @param $parameters
*/
public function postDatabaseQuery($medoo, $parameters)
......@@ -146,7 +148,7 @@
'sql_driver' => $medoo_info['driver'],
'sql_version' => $medoo_info['version'],
'sql_connection' => $medoo_info['connection'],
'sql_last_query' => $medoo->last_query(),
'sql_last_query' => $medoo->last(),
'php_version' => phpversion(),
'core_version' => $this->appClass->getSetting("version", "0.0.0.1", true)
)
......
<?php
namespace Core;
namespace Core\Analytics;
require_once(dirname(__FILE__) . "/../../autoloader.php");
/**
* tracking
......@@ -32,7 +34,6 @@
public function __construct($trackingId, $api_url)
{
$this->setSiteId($trackingId);