Compare commits

...

4 Commits

Author SHA1 Message Date
slawkens1
b83fb05b82 * update to 0.7.4 2017-12-24 09:50:53 +01:00
slawkens1
cf12265cd8 * fixed displaying of percent bar on tibian signature 2017-12-24 09:37:28 +01:00
slawkens1
e4110a6981 * automatically update highscores_ids_hidden for users who installed myaac before
* update TODO
2017-12-21 22:08:47 +01:00
slawkens1
412908026d * inform user about Twig cache failure on installation, instead of http 500 error
* when dir system/cache is not writable by the webserver, then show some
nice notice to the user about it instead of http 500 error
* remember client version and usage stats checkbox in session on install
* fixed some small warning introducted yesterday about
highscores_ids_hidden
* updated TODO
2017-12-19 23:32:30 +01:00
16 changed files with 131 additions and 43 deletions

View File

@@ -1,6 +1,14 @@
[0.7.4 - 24.12.2017]
* fixed mysql fatal error on tibiacom template - top 5 box
* fixed displaying of level percent bar on tibian signature
* inform user about Twig cache failure on installation, instead of http 500 error
* when dir system/cache is not writable by the webserver, then show some nice notice to the user about it instead of http 500 error
* remember client version select and usage stats checkbox in session on install
* automatically update highscores_ids_hidden for users who installed myaac before (migration)
[0.7.3 - 18.12.2017]
* auto generate myaac cache & session prefix on install to be unique accross installations
* fixed hidding shop system menu on tibiacom template when disabled in config
* auto generate myaac cache & session prefix on install to be unique across installations
* fixed hiding shop system menu on tibiacom template when disabled in config
* prevent adding duplicated newses with installation
* some changes to sample characters: chanced town_id to 1, posx: 1000, posy: 1000, posz: 1000 and default group_id to 1 so you can change in-game outfits and they will be used
* added version 772 constant to install client choose (OTHire)

9
TODO
View File

@@ -3,20 +3,19 @@
0.*
* support duplicated vocation names with different ids
* plugins: option to define custom requirements check in json file, to check if system meets the requirement
* inform user about Twig cache failure on installation, instead of 500 error
* add support for defining max myaac version in plugin.json file
* cache Menus in templates
* don't show error indicators on first time load - createaccount page
* update Twig to the latest version from 1.x branch
* semantic versioning support for plugins (github.com/composer/semver)
* database towns table support for TFS 1.3
* players.is_sample is waste, better save in config.php array of ignored ids
* add some notice to the user that installing step "Import Schema" will take some time
* remember client version in session on install
* check user IP on installing to prevent install by random user
1.0:
* i18n support (issue #1 on github)
* New Admin Panel layout and interface
* add changelog management interface
* remove tibiacom template, and include it as a plugin
2.0
* remove compat functions
@@ -24,6 +23,7 @@
* var/ (for logs, cache and data), config/, bin, public/ (for index and images and other public content), system/ (for php files and classess)
* rename templates to layouts as templates is meant to be used for twig templates
* change gifts_system to shop_system configurable
* move most used options in system/templates dir to separate directories (more transparent)
At any time between (version not specified):
* better news archive with search function (like on tibia.com)
@@ -34,3 +34,4 @@ At any time between (version not specified):
* preferably configurable (enable/disable) forum TinyMCE editor
* new cache engine - plain php, is good with pure php 7.0+ and opcache
* OTAdmin support in Admin Panel
* database towns table support for TFS 1.3

View File

@@ -26,8 +26,8 @@
session_start();
define('MYAAC', true);
define('MYAAC_VERSION', '0.7.3');
define('DATABASE_VERSION', 19);
define('MYAAC_VERSION', '0.7.4');
define('DATABASE_VERSION', 20);
define('TABLE_PREFIX', 'myaac_');
define('START_TIME', microtime(true));
define('MYAAC_OS', (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? 'WINDOWS' : (strtoupper(PHP_OS) == 'DARWIN' ? 'MAC' : 'LINUX'));

View File

@@ -186,6 +186,7 @@ $config = array(
'highscores_outfit' => true, // show player outfit?
'highscores_country_box' => false, // doesnt work yet! (not implemented)
'highscores_groups_hidden' => 4, // this group id and higher won't be shown on the highscores
'highscores_ids_hidden' => array(0), // this ids of players will be hidden on the highscores (should be ids of samples)
'highscores_length' => 100, // how many records per page on highscores
// characters page

View File

@@ -78,4 +78,23 @@ function next_form($previous = true, $next = true)
<input type="hidden" name="step" id="step" value="' . $step . '" />' . next_buttons($previous, $next) . '
</form>';
}
?>
function win_is_writable($path) {
if($path[strlen( $path ) - 1] == '/') { // if it looks like a directory, check a random file within the directory
return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp');
} elseif(is_dir( $path )) { // If it's a directory (and not a file) check a random file within the directory
return win_is_writable( $path . '/' . uniqid( mt_rand() ) . '.tmp' );
}
// check tmp file for read/write capabilities
$should_delete_tmp_file = !file_exists( $path );
$f = @fopen( $path, 'a' );
if ( $f === false )
return false;
fclose( $f );
if($should_delete_tmp_file)
unlink($path);
return true;
}

View File

@@ -0,0 +1,11 @@
We have detected that you don't have access to write to the system/cache directory. Under linux you can fix it by using this two command, where first one should be enough (for apache):<br/><br/><span class="console">chown -R www-data.www-data /var/www/*</span><br/><span class="console">chmod -R 660 system/cache</span>
<style type="text/css">
.console {
font-family:Courier;
color: #CCCCCC;
background: #000000;
border: 3px double #CCCCCC;
padding: 0px;
}
</style>

View File

@@ -91,16 +91,19 @@ else if($step == 'finish') {
$error = false;
// step include
ob_start();
clearstatcache();
if(is_writable(CACHE) && (MYAAC_OS != 'WINDOWS' || win_is_writable(CACHE))) {
ob_start();
$step_id = array_search($step, $steps);
require('steps/' . $step_id . '-' . $step . '.php');
$content = ob_get_contents();
ob_end_clean();
$step_id = array_search($step, $steps);
require('steps/' . $step_id . '-' . $step . '.php');
$content = ob_get_contents();
ob_end_clean();
}
else {
$content = error(file_get_contents(BASE . 'install/includes/twig_error.html'), true);
}
// render
require('template/template.php');
//$_SESSION['laststep'] = $step;
?>

View File

@@ -240,9 +240,9 @@ if(!$error) {
$content .= PHP_EOL;
$content .= '$config[\'client_download_linux\'] = \'http://tibia-clients.com/clients/download/\'. $config[\'client\'] . \'/tar/linux\';';
$content .= PHP_EOL;
$content .= '$config[\'session_prefix\'] = \'myaac_' . generateRandomString(8, true, false, true, false) . '\';';
$content .= '$config[\'session_prefix\'] = \'myaac_' . generateRandomString(8, true, false, true, false) . '_\';';
$content .= PHP_EOL;
$content .= '$config[\'cache_prefix\'] = \'myaac_' . generateRandomString(8, true, false, true, false) . '\';';
$content .= '$config[\'cache_prefix\'] = \'myaac_' . generateRandomString(8, true, false, true, false) . '_\';';
$content .= PHP_EOL;
$file = fopen(BASE . 'config.local.php', 'a+');

View File

@@ -149,8 +149,8 @@ $config['data_path'] = $tmp;
unset($tmp);
// new config values for compability
if($config['highscores_ids_hidden'] == null) {
$config['highscores_ids_hidden'] = array();
if(!isset($config['highscores_ids_hidden']) || count($config['highscores_ids_hidden']) == 0) {
$config['highscores_ids_hidden'] = array(0);
}
// POT

View File

@@ -3152,6 +3152,14 @@ class OTS_Player extends OTS_Row_DAO
$this->db->query('DELETE FROM ' . $this->db->tableName('player_spells') . ' WHERE ' . $this->db->fieldName('player_id') . ' = ' . $this->data['id'] . ' AND ' . $this->db->fieldName('name') . ' = ' . $this->db->quote( $spell->getName() ) );
}
public static function getPercentLevel($count, $nextLevelCount)
{
if($nextLevelCount > 0)
return min(100, max(0, $count * 100 / $nextLevelCount));
return 0;
}
/**
* Magic PHP5 method.
*

View File

@@ -30,11 +30,9 @@ class OTS_Toolbox
*/
public static function experienceForLevel($level, $experience = 0)
{
return 50 * ($level - 1) * ($level * $level - 5 * $level + 12) / 3 - $experience;
/*
//return 50 * ($level - 1) * ($level * $level - 5 * $level + 12) / 3 - $experience;
$level = $level - 1;
return ((50 * $level * $level * $level) - (150 * $level * $level) + (400 * $level)) / 3;
*/
}
/**

View File

@@ -1,3 +1,3 @@
<?php
// this migrations has been removed, but file kept for compability
// this migration has been removed, but file kept for compability
?>

39
system/migrations/20.php Normal file
View File

@@ -0,0 +1,39 @@
<?php
$config_file = BASE . 'config.local.php';
if(!is_writable($config_file)) { // we can't do anything, just ignore
return;
}
$content_of_file = trim(file_get_contents($config_file));
if(strpos($content_of_file, 'highscores_ids_hidden') !== false) { // already present
return;
}
$query = $db->query("SELECT `id` FROM `players` WHERE (`name` = " . $db->quote("Rook Sample") . " OR `name` = " . $db->quote("Sorcerer Sample") . " OR `name` = " . $db->quote("Druid Sample") . " OR `name` = " . $db->quote("Paladin Sample") . " OR `name` = " . $db->quote("Knight Sample") . ") ORDER BY `id`;");
$highscores_ignored_ids = array();
if($query->rowCount() > 0) {
foreach($query->fetchAll() as $result)
$highscores_ignored_ids[] = $result['id'];
}
else {
$highscores_ignored_ids[] = 0;
}
$php_on_end = substr($content_of_file, -2, 2) == '?>';
$content = PHP_EOL;
if($php_on_end) {
$content .= '<?php';
}
$content .= PHP_EOL;
$content .= '$config[\'highscores_ids_hidden\'] = array(' . implode(', ', $highscores_ignored_ids) . ');';
$content .= PHP_EOL;
if($php_on_end) {
$content .= '?>';
}
file_put_contents($config_file, $content, FILE_APPEND);
?>

View File

@@ -23,7 +23,7 @@
<br/>
<select name="vars[client]" id="vars_client">
{% for id, version in clients %}
<option value="{{ id }}">{{ version }}</option>
<option value="{{ id }}"{% if session['var_client'] is not null and session['var_client'] == id %} selected{% endif %}>{{ version }}</option>
{% endfor %}
</select>
</td>
@@ -38,7 +38,7 @@
</label>
<br/>
<input type="hidden" value="0" name="vars[usage]">
<input type="checkbox" name="vars[usage]" id="vars_usage" value="1" checked/>
<input type="checkbox" name="vars[usage]" id="vars_usage" value="1"{% if session['var_usage'] is null or session['var_usage'] == 1 %} checked{% endif %}/>
</td>
<td>
<em>{{ locale.step_config_usage_desc }}</em>

View File

@@ -406,10 +406,6 @@ foreach($config['menu_categories'] as $id => $cat) {
</div>
<div id="ThemeboxesColumn">
<div id="RightArtwork">
<?php
//$tmp_link =
//if($config['friendly_urls'])
?>
<img id="Monster" src="images/monsters/<?php echo logo_monster() ?>.gif" onClick="window.location = '?subtopic=creatures&creature=<?php echo $config['logo_monster'] ?>';" alt="Monster of the Week" />
<img id="PedestalAndOnline" src="<?php echo $template_path; ?>/images/header/pedestal-and-online.gif" alt="Monster Pedestal and Players Online Box"/>
<div id="PlayersOnline" onClick="window.location = '<?php echo getLink('online'); ?>'">
@@ -430,8 +426,7 @@ foreach($config['menu_categories'] as $id => $cat) {
<?php
}
}
?>
<?php
if($config['template_allow_change'])
echo '<font color="white">Template:</font><br/>' . template_form();
?>

View File

@@ -30,12 +30,17 @@
imagettftext($img, $fontsize, 0, 100, 43, $text, $font, number_format($player->getLevel()));
// experience bar
$exppercent = round($experience / $needexp * 100);
imagerectangle($img, 14, 46, 166, 50, $bar);
if($exppercent > 0)
imagefilledrectangle($img, 15, 47, $exppercent * 1.5 + 15, 49, $barfill);
$currLevelExp = OTS_Toolbox::experienceForLevel($player->getLevel());
$nextLevelExp = OTS_Toolbox::experienceForLevel($player->getLevel() + 1);
$levelPercent = 0;
if($nextLevelExp > $currLevelExp)
$levelPercent = (int)OTS_Player::getPercentLevel($experience - $currLevelExp, $nextLevelExp - $currLevelExp);
imagettftext($img, $fontsize, 0, 170, 51, $text, $font, $exppercent . '%');
imagerectangle($img, 14, 46, 166, 50, $bar);
if($levelPercent > 0)
imagefilledrectangle($img, 15, 47, $levelPercent * 1.5 + 15, 49, $barfill);
imagettftext($img, $fontsize, 0, 170, 51, $text, $font, $levelPercent . '%');
// vocation
$vocation = 'Unknown';