Skip to content

Commit

Permalink
Merge pull request #98 from Erwane/1.8
Browse files Browse the repository at this point in the history
disable mushraider.com checks
  • Loading branch information
st3ph authored Jun 3, 2021
2 parents 1f2af9d + f42977a commit 90ef048
Show file tree
Hide file tree
Showing 50 changed files with 267 additions and 233 deletions.
15 changes: 11 additions & 4 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*.properties text
*.txt text
*.xml text
*.svg text
*.yml text
.htaccess text

Expand All @@ -34,10 +35,16 @@
*.mo binary
*.pdf binary
*.phar binary
*.otf binary
*.eot binary
*.svg binary
*.ttf binary
*.woff binary
*.woff2 binary
*.mp4 binary
*.ttf binary
*.otf binary
*.eot binary
*.gz binary
*.bz2 binary
*.7z binary
*.zip binary
*.docx binary
*.xlsx binary
*.mmdb binary
29 changes: 28 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
/app/tmp/cache/views/*
/app/webroot/files/*

/storage
/vendor

# OS generated files #
######################
.DS_Store
Expand All @@ -17,4 +20,28 @@
.Trashes
Icon?
ehthumbs.db
Thumbs.db
Thumbs.db

# Tool specific files #
#######################
# vim
*~
*.swp
*.swo
# sublime text & textmate
*.sublime-*
*.stTheme.cache
*.tmlanguage.cache
*.tmPreferences.cache
# Eclipse
.settings/*
# JetBrains, aka PHPStorm, IntelliJ IDEA
.idea/*
# NetBeans
nbproject/*
# Visual Studio Code
.vscode
# Sass preprocessor
.sass-cache/
/.phpstorm.meta.php
/.phpunit.result.cache
2 changes: 1 addition & 1 deletion app/Config/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@


Configure::write('debug', 0);
Configure::write('mushraider', array('version' => '1.7.0.4', 'date' => '2019-12-12'));
Configure::write('mushraider', array('version' => '1.8.0.0', 'date' => '2021-06-03'));

/**
* Configure the Error handler used to handle errors for your application. By default
Expand Down
4 changes: 2 additions & 2 deletions app/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public function beforeFilter() {
parent::beforeFilter();

// Check conf file
if(!file_exists('../Config/config.ini')) {
file_put_contents('../Config/config.ini', '');
if(!file_exists(CONFIG . 'config.ini')) {
file_put_contents(CONFIG . 'config.ini', '');
}

Configure::config('configini', new IniReader());
Expand Down
26 changes: 15 additions & 11 deletions app/Plugin/Admin/Controller/AdminAppController.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
App::uses('HttpSocket', 'Network/Http');
class AdminAppController extends AppController {
public $components = array('Admin.Mushstats');
public $uses = array();
public $helpers = array('Admin.Admin');

Expand Down Expand Up @@ -40,18 +39,23 @@ private function checkUpdate() {
$mushraider['version'] = 0;
$mushraider['date'] = '0000-00-00';
}
$jsonUrl = 'http://medias.mushraider.com/version.json';

$jsonUrl = 'https://api.github.com/repos/st3ph/mushraider/tags?per_page=1';
$HttpSocket = new HttpSocket(['timeout' => 1]);
$response = $HttpSocket->get($jsonUrl);
if (empty($response->body)) {
return;
if ($response->isOk()) {
$tag = json_decode($response->body);
if (!$tag) {
return;
}
$lastVersion = str_replace('v', '', $tag[0]->name);

// Check if version is different
// Be sure the server is newer than the current app
if(version_compare($mushraider['version'], $lastVersion, '<')) {
$updateMsg = __('<strong>MushRaider %s</strong> is available! <a href="https://github.com/st3ph/mushraider/tags" target="_blank">Please update now</a>', $lastVersion);
$this->set('updateAvailable', $updateMsg);
}
}
$lastVersion = json_decode($response->body);
// Check if version is different
// Be sure the server is newer than the current app
if(($mushraider['version'] != $lastVersion->version && $mushraider['date'] < $lastVersion->date) || ($mushraider['version'] == $lastVersion->version && $mushraider['date'] < $lastVersion->date)) {
$updateMsg = __('<strong>MushRaider %s</strong> is available! <a href="http://mushraider.com/download" target="_blank">Please update now</a>', $lastVersion->version);
$this->set('updateAvailable', $updateMsg);
}
}
}
18 changes: 9 additions & 9 deletions app/Plugin/Admin/Controller/PatcherController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ public function apply($patch = null) {
if(!empty($this->request->data['Patcher'])) {
$db = ConnectionManager::getDataSource('default');
$db->cacheSources = false;

$error = false;
$databaseConfig = Configure::read('Database');
$this->dbPrefix = $databaseConfig['prefix'];
if(!$mysqlLink = mysqli_connect($databaseConfig['host'], $databaseConfig['login'], $databaseConfig['password'], $databaseConfig['database'], $databaseConfig['port'])) {
$error = true;
}
$sqlReport = $this->Patcher->run_sql_file($mysqlLink, '../Config/Schema/sql/mushraider_patch_'.$patch.'.sql', $this->dbPrefix);

$sqlReport = $this->Patcher->run_sql_file($mysqlLink, CONFIG . 'Schema/sql/mushraider_patch_'.$patch.'.sql', $this->dbPrefix);
$mysqlLink = null;

if($sqlReport['success'] != $sqlReport['total']) {
Expand All @@ -46,11 +46,11 @@ public function apply($patch = null) {
Cache::clear(false, '_cake_core_');
Cache::clear(false, '_cake_model_');
Cache::clear(false);

$methodName = str_replace('-', '', $patch);
$methodName = str_replace('.', '', $methodName);
if(method_exists($this, $methodName)) {
$this->$methodName();
$this->$methodName();
}

// Delete cache for obvious reasons :p
Expand Down Expand Up @@ -94,7 +94,7 @@ public function beta3() {
}else {
$toSaveCharacter['created'] = date('Y-m-d H:i:s');
}

$this->Character->save($toSaveCharacter);
}
}
Expand Down Expand Up @@ -198,11 +198,11 @@ public function v15() {

$this->Setting->setOption('calendar', json_encode($calendar));

// Set main characters
// Set main characters
$sql = "SELECT t.user_id, t.game_id, t.character_id, MAX(t.used) AS nb_used
FROM (
SELECT ec.user_id, e.game_id, ec.character_id, COUNT(ec.id) AS used
FROM ".$this->dbPrefix."events_characters ec
FROM ".$this->dbPrefix."events_characters ec
JOIN ".$this->dbPrefix."users u ON ec.user_id=u.id
JOIN ".$this->dbPrefix."events e ON e.id=ec.event_id
GROUP BY ec.character_id
Expand Down Expand Up @@ -302,4 +302,4 @@ public function v162() {
$notifications['comments'] = 0;
$this->Setting->setOption('notifications', json_encode($notifications));
}
}
}
6 changes: 3 additions & 3 deletions app/Plugin/Admin/webroot/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ span.formTip {font-size:11px;font-style:italic;}
webkit-transition: all 0.4s ease-out 0s;
-moz-transition: all 0.4s ease-out 0s;
-o-transition: all 0.4s ease-out 0s;
transition: all 0.4s ease-out 0s;
transition: all 0.4s ease-out 0s;
}
#menu ul li a:hover {padding-left:15px;}
.form-group {margin-bottom:10px;}
Expand Down Expand Up @@ -1254,7 +1254,7 @@ table.table-striped tbody.ui-sortable tr.sortable-placeholder td:last-child {bor
.quick-btn .waiting {position: absolute;right: -5px;bottom: -5px;top:auto;}
#mushInfos {margin-top:100px;}
#mushInfos .lead {text-shadow:2px 2px #fff;}
#mushInfos .social {text-align;:center;}
#mushInfos .social {text-align:center;}
#mushInfos .social li {vertical-align:top}
#mushInfos .social li.googleplus {padding-top:2px;}

Expand Down Expand Up @@ -1296,4 +1296,4 @@ table.table-striped tbody.ui-sortable tr.sortable-placeholder td:last-child {bor
#summary {margin-bottom:50px;}

/* Widget */
.integrationCode textarea {width:90%;}
.integrationCode textarea {width:90%;}
14 changes: 7 additions & 7 deletions app/Plugin/Install/Controller/InstallAppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
App::uses('IniReader', 'Configure');
App::uses('Controller', 'Controller');
class InstallAppController extends Controller {
public function beforeFilter() {
public function beforeFilter() {
parent::beforeFilter();

if(!file_exists('../Config/config.ini')) {
file_put_contents('../Config/config.ini', '');
if(!file_exists(CONFIG . 'config.ini')) {
file_put_contents(CONFIG . 'config.ini', '');
}

Configure::config('configini', new IniReader());
Configure::load('config.ini', 'configini');

// If config already set, redirect to root
if(file_exists('../Config/config.ini')) {
if(file_exists(CONFIG . 'config.ini')) {
if(Configure::read('Settings.installed')) {
$this->Session->setFlash(__('MushRaider can see the database config, why do you want to install ?'), 'flash_warning');
$this->redirect('/');
$this->redirect('/');
}
}

Expand All @@ -25,4 +25,4 @@ public function beforeFilter() {
$languages = array('eng' => 'English', 'fra' => 'Français', 'deu' => 'Deutsch');
$this->set('languages', $languages);
}
}
}
20 changes: 10 additions & 10 deletions app/Plugin/Install/Controller/StepController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ private function step1() {
$systemCheck['rewrite']['warning'] = true;
}

$systemCheck['config']['passed'] = is_writable('../Config')?true:false;
$systemCheck['config']['passed'] = is_writable(CONFIG);
$systemCheckPassed = $systemCheck['config']['passed']?$systemCheckPassed:false;
$systemCheck['tmp']['passed'] = is_writable('../tmp')?true:false;
$systemCheck['tmp']['passed'] = is_writable(APP . 'tmp');
$systemCheckPassed = $systemCheck['tmp']['passed']?$systemCheckPassed:false;
$systemCheck['files']['passed'] = is_writable('../webroot/files')?true:false;
$systemCheck['files']['passed'] = is_writable(APP . 'webroot/files');
$systemCheckPassed = $systemCheck['files']['passed']?$systemCheckPassed:false;

$this->set('systemCheckPassed', $systemCheckPassed);
Expand All @@ -52,7 +52,7 @@ private function step1() {

private function step2() {
$this->Session->delete('Settings');

if(!empty($this->request->data['Config'])) {
$dataSource = !empty($this->request->data['Config']['datasource']) && !empty($this->dbDatasources[$this->request->data['Config']['datasource']])?$this->dbDatasources[$this->request->data['Config']['datasource']]:'Mysql';

Expand All @@ -62,7 +62,7 @@ private function step2() {
$databaseConfig['database'] = trim($this->request->data['Config']['database']);
$databaseConfig['login'] = trim($this->request->data['Config']['login']);
$databaseConfig['password'] = $this->request->data['Config']['password'];
$databaseConfig['port'] = !empty($this->request->data['Config']['port'])?trim($this->request->data['Config']['port']):ini_get("mysqli.default_port");
$databaseConfig['port'] = !empty($this->request->data['Config']['port'])?trim($this->request->data['Config']['port']):ini_get("mysqli.default_port");
$databaseConfig['prefix'] = trim($this->request->data['Config']['prefix']);

if($link = @mysqli_connect($databaseConfig['host'], $databaseConfig['login'], $databaseConfig['password'], $databaseConfig['database'], $databaseConfig['port'])) {
Expand Down Expand Up @@ -110,12 +110,12 @@ private function step3() {
$error = true;
}
// Create tables
$sqlReport = $this->Patcher->run_sql_file($mysqlLink, '../Config/Schema/sql/mushraider.sql', $databaseConfig['prefix']);
$sqlReport = $this->Patcher->run_sql_file($mysqlLink, CONFIG . 'Schema/sql/mushraider.sql', $databaseConfig['prefix']);
if($sqlReport['success'] != $sqlReport['total']) {
$error = true;
}
// Add datas
$sqlReport = $this->Patcher->run_sql_file($mysqlLink, '../Config/Schema/sql/mushraider_data.sql', $databaseConfig['prefix']);
$sqlReport = $this->Patcher->run_sql_file($mysqlLink, CONFIG . 'Schema/sql/mushraider_data.sql', $databaseConfig['prefix']);
if($sqlReport['success'] != $sqlReport['total']) {
$error = true;
}
Expand Down Expand Up @@ -180,7 +180,7 @@ public function step4() {

private function postInstallData($siteTitle) {
// Add default settings
$host = substr_count($_SERVER['HTTP_HOST'], '.') > 1?substr($_SERVER['HTTP_HOST'], strpos($_SERVER['HTTP_HOST'], '.') + 1):$_SERVER['HTTP_HOST'];
$host = substr_count($_SERVER['HTTP_HOST'], '.') > 1?substr($_SERVER['HTTP_HOST'], strpos($_SERVER['HTTP_HOST'], '.') + 1):$_SERVER['HTTP_HOST'];
$host = strpos($host, ':') !== false?substr($host, 0, strpos($host, ':')):$host; // Remove port if present on unusual configurations

App::uses('Setting', 'Model');
Expand Down Expand Up @@ -219,7 +219,7 @@ private function postInstallData($siteTitle) {
'dungeonIcon' => 1
));
$defaultSettings['timezone'] = 'Europe/Paris';

foreach($defaultSettings as $option => $value) {
$settingModel->create();
$settingModel->save(array('option' => $option, 'value' => $value));
Expand Down Expand Up @@ -252,4 +252,4 @@ private function postInstallData($siteTitle) {
$RolePermissionRoleModel->__add(array('role_id' => $RoleModel->getIdByAlias('officer'), 'role_permission_id' => $RolePermissionModel->getIdByAlias('create_templates')));
$RolePermissionRoleModel->__add(array('role_id' => $RoleModel->getIdByAlias('officer'), 'role_permission_id' => $RolePermissionModel->getIdByAlias('create_reports')));
}
}
}
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/CompletionShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function getOptionParser() {
*/
protected function _output($options = array()) {
if ($options) {
return $this->out(implode($options, ' '));
return $this->out(implode(' ', $options));
}
}
}
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/SchemaShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function startup() {
$this->out('Cake Schema Shell');
$this->hr();

Configure::write('Cache.disable', 1);
Configure::write('Cache.disable', true);

$name = $path = $connection = $plugin = null;
if (!empty($this->params['name'])) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/Task/ModelTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ public function initValidations() {
sort($options);
$default = 1;
foreach ($options as $option) {
if ($option{0} !== '_') {
if ($option[0] !== '_') {
$choices[$default] = $option;
$default++;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Console/Command/TestShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ protected function _run($runnerArgs, $options = array()) {
public function available() {
$params = $this->_parseArgs();
$testCases = CakeTestLoader::generateTestList($params);
$app = $params['app'];
$plugin = $params['plugin'];
$app = isset($params['app']) ? $params['app'] : null;
$plugin = isset($params['plugin']) ? $params['plugin'] : null;

$title = "Core Test Cases:";
$category = 'core';
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/UpgradeShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public function helpers() {
foreach ($helpers as $helper) {
$helper = preg_replace('/Helper$/', '', $helper);
$oldHelper = $helper;
$oldHelper{0} = strtolower($oldHelper{0});
$oldHelper[0] = strtolower($oldHelper[0]);
$patterns[] = array(
"\${$oldHelper} to \$this->{$helper}",
"/\\\${$oldHelper}->/",
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Console/ConsoleOptionParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,8 @@ protected function _optionExists($name) {
if (substr($name, 0, 2) === '--') {
return isset($this->_options[substr($name, 2)]);
}
if ($name{0} === '-' && $name{1} !== '-') {
return isset($this->_shortOptions[$name{1}]);
if ($name[0] === '-' && $name[1] !== '-') {
return isset($this->_shortOptions[$name[1]]);
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/ConsoleOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ protected function _replaceTags($matches) {
$styleInfo[] = static::$_options[$option];
}
}
return "\033[" . implode($styleInfo, ';') . 'm' . $matches['text'] . "\033[0m";
return "\033[" . implode(';', $styleInfo) . 'm' . $matches['text'] . "\033[0m";
}

/**
Expand Down
Loading

0 comments on commit 90ef048

Please sign in to comment.