PHP 5.4.10For me, it's loading in milliseconds too. What PHP version and web server are you using?
lol I noticed that some pages load faster than others immediately in milliseconds but others have 1 second delay
PHP 5.4.10For me, it's loading in milliseconds too. What PHP version and web server are you using?
Which pages load faster and which slower?PHP 5.4.10
lol I noticed that some pages load faster than others immediately in milliseconds but others have 1 second delay
hmm it's not page fault because it happens irregulary one time page loads immediately next time in 1 secondWhich pages load faster and which slower?
Warning: file_get_contents(http://my-aac.org/report_install.php?v=0.3.0&b=http%3A%2F%2Flocalhost%2F): failed to open stream: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? in \install\steps\finish.php on line 188
at the end of installation I get warning
Code:Warning: file_get_contents(http://my-aac.org/report_install.php?v=0.3.0&b=http%3A%2F%2Flocalhost%2F): failed to open stream: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP? in \install\steps\finish.php on line 188
alright but I don't know what with slow pages loading :/
I mention before WebServYou can try installing some cache engine like XCache, eAccelerator or APC. Or you can update your php to higher version cause it seems pretty outdated. I ask again - what web server are you using? If xampp, then try updating to newest version.
I mention before WebServ
ye but so far all gesior acc makers worked flawlesslyThen, the latest version of this WebServ is from 2013, its 4 years outdated. Use XAMPP instead.
Download XAMPP
Use version 7.1.8
How to update?
When I check for updates it says "MyAAC latest version is 0.3.0. You're using the latest version. "
Should I reinstall it ? :/
Fatal error: An iterator cannot be used with foreach by reference in E:\xampp\htdocs\system\pages\characters.php on line 169
<?php
/**
* Characters
*
* @package MyAAC
* @author Gesior <[email protected]>
* @author Slawkens <[email protected]>
* @copyright 2017 MyAAC
* @version 0.4.2
* @link http://my-aac.org
*/
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Characters';
require(SYSTEM . 'item.php');
$groups = new OTS_Groups_List();
function generate_search_form($autofocus = false)
{
global $config, $twig;
return $twig->render('characters.form.html.twig', array(
'link' => getPageLink('characters'),
'vdarkborder' => $config['vdarkborder'],
'darkborder' => $config['darkborder'],
'autofocus' => $autofocus
));
}
function retrieve_former_name($name)
{
global $oldName, $db;
if(tableExist('player_namelocks') && fieldExist('name', 'player_namelocks')) {
$newNameSql = $db->query('SELECT `name`, `new_name` FROM `player_namelocks` WHERE `name` = ' . $db->quote($name));
if($newNameSql->rowCount() > 0) // namelocked
{
$newNameSql = $newNameSql->fetch();
$oldName = ' (<small><b>Former name:</b> ' . $newNameSql['name'] . '</small>)';
return $newNameSql['new_name'];
}
}
return '';
}
$name = '';
if(isset($_REQUEST['name']))
$name = stripslashes(ucwords(strtolower(trim($_REQUEST['name']))));
if(empty($name))
{
$tmp_link = getPlayerLink($name);
echo 'Here you can get detailed information about a certain player on ' . $config['lua']['serverName'] . '.<BR>';
echo generate_search_form(true);
return;
}
$name = str_replace('/', '', $name);
$oldName = '';
$player = $ots->createObject('Player');
$player->find($name);
if(!$player->isLoaded())
{
$tmp_zmienna = "";
$tmp_name = retrieve_former_name($name);
while(!empty($tmp_name))
{
$tmp_zmienna = $tmp_name;
$tmp_name = retrieve_former_name($tmp_zmienna);
}
if(!empty($tmp_zmienna))
$player->find($tmp_zmienna);
}
if($player->isLoaded() && !$player->isDeleted())
{
$title = $player->getName() . ' - ' . $title;
$account = $player->getAccount();
$rows = 0;
if($config['characters']['outfit'])
$outfit = $config['outfit_images_url'] . '?id=' . $player->getLookType() . (fieldExist('lookaddons', 'players') ? '&addons=' . $player->getLookAddons() : '') . '&head=' . $player->getLookHead() . '&body=' . $player->getLookBody() . '&legs=' . $player->getLookLegs() . '&feet=' . $player->getLookFeet();
$flag = '';
if($config['account_country'])
$flag = getFlagImage($account->getCustomField('country'));
$player_sex = 'Unknown';
if(isset($config['genders'][$player->getSex()]))
$player_sex = strtolower($config['genders'][$player->getSex()]);
$marriage = new OTS_Player();
$marriage->load($player->getMarriage());
$marital_status = 'single';
if($marriage->isLoaded())
$marital_status = 'married to ' . getPlayerLink($marriage->getName());
$frags_enabled = tableExist('player_killers') && $config['characters']['frags'];
$frags_count = 0;
if($frags_enabled) {
$query = $db->query(
'SELECT COUNT(`player_id`) as `frags`' .
'FROM `player_killers`' .
'WHERE `player_id` = ' .$player->getId() . ' ' .
'GROUP BY `player_id`' .
'ORDER BY COUNT(`player_id`) DESC');
if($query->rowCount() > 0)
{
$query = $query->fetch();
$frags_count = $query['frags'];
}
}
$town_field = 'town';
if(fieldExist('town_id', 'houses'))
$town_field = 'town_id';
else if(fieldExist('townid', 'houses'))
$town_field = 'townid';
else if(!fieldExist('town', 'houses'))
$town_field = false;
if(fieldExist('name', 'houses')) {
$house = $db->query('SELECT `id`, `paid`, `name`' . ($town_field != false ? ', `' . $town_field . '` as `town`' : '') . ' FROM `houses` WHERE `owner` = '.$player->getId())->fetch();
if(isset($house['id']))
{
$add = '';
if($house['paid'] > 0)
$add = ' is paid until '.date("M d Y", $house['paid']);
}
}
$rank_of_player = $player->getRank();
if($rank_of_player->isLoaded()) {
$guild = $rank_of_player->getGuild();
if($guild->isLoaded()) {
$guild_name = $guild->getName();
}
}
$comment = $player->getComment();
if($config['characters']['skills'])
{
if(fieldExist('skill_fist', 'players')) {// tfs 1.0+
$skills_db = $db->query('SELECT `skill_fist`, `skill_club`, `skill_sword`, `skill_axe`, `skill_dist`, `skill_shielding`, `skill_fishing` FROM `players` WHERE `id` = ' . $player->getId())->fetch();
$skill_ids = array(
POT::SKILL_FIST => 'skill_fist',
POT::SKILL_CLUB => 'skill_club',
POT::SKILL_SWORD => 'skill_sword',
POT::SKILL_AXE => 'skill_axe',
POT::SKILL_DIST => 'skill_dist',
POT::SKILL_SHIELD => 'skill_shielding',
POT::SKILL_FISH => 'skill_fishing',
);
$skills = array();
foreach($skill_ids as $skillid => $field_name) {
$skills[] = array('skillid' => $skillid, 'value' => $skills_db[$field_name]);
}
}
else
$skills = $db->query('SELECT `skillid`, `value` FROM `player_skills` WHERE `player_id` = ' . $player->getId() . ' LIMIT 7');
foreach($skills as &$skill) {
$skill['name'] = getSkillName($skill['skillid']);
}
}
$quests_enabled = $config['characters']['quests'] && !empty($config['quests']);
if($quests_enabled)
{
$quests = $config['quests'];
$sql_query_in = '';
$i = 0;
foreach($quests as $quest_name => $quest_storage)
{
if($i != 0)
$sql_query_in .= ', ';
$sql_query_in .= $quest_storage;
$i++;
}
$storage_sql = $db->query('SELECT `key`, `value` FROM `player_storage` WHERE `player_id` = '.$player->getId().' AND `key` IN (' . $sql_query_in . ')');
$player_storage = array();
foreach($storage_sql as $storage)
$player_storage[$storage['key']] = $storage['value'];
foreach($quests as &$storage) {
$storage = isset($player_storage[$storage]) && $player_storage[$storage] > 0;
}
}
if($config['characters']['equipment'])
{
global $db;
$eq_sql = $db->query('SELECT `pid`, `itemtype` FROM player_items WHERE player_id = '.$player->getId().' AND (`pid` >= 1 and `pid` <= 10)');
$equipment = array();
foreach($eq_sql as $eq)
$equipment[$eq['pid']] = $eq['itemtype'];
$empty_slots = array("", "no_helmet", "no_necklace", "no_backpack", "no_armor", "no_handleft", "no_handright", "no_legs", "no_boots", "no_ring", "no_ammo");
for($i = 0; $i <= 10; $i++)
{
if(!isset($equipment[$i]) || $equipment[$i] == 0)
$equipment[$i] = $empty_slots[$i];
}
for($i = 1; $i < 11; $i++)
{
if(check_number($equipment[$i]))
$equipment[$i] = getItemImage($equipment[$i]);
else
$equipment[$i] = '<img src="images/items/' . $equipment[$i] . '.gif" width="32" height="32" border="0" alt=" ' . $equipment[$i] . '" />';
}
$skulls = array(
1 => 'yellow_skull',
2 => 'green_skull',
3 => 'white_skull',
4 => 'red_skull',
5 => 'black_skull'
);
}
$dead_add_content = '';
if(tableExist('killers')) {
$player_deaths = $db->query('SELECT `id`, `date`, `level` FROM `player_deaths` WHERE `player_id` = '.$player->getId().' ORDER BY `date` DESC LIMIT 0,10;');
if(count($player_deaths))
{
$dead_add_content = '<br/><table border=0 cellspacing=1 cellpadding=4 width=100%><tr bgcolor='.$config['vdarkborder'].'><td colspan=2 class="white"><b>Character Deaths</b></td></tr>';
$number_of_rows = 0;
foreach($player_deaths as $death)
{
$dead_add_content .= '<tr bgcolor="'.getStyle($number_of_rows++).'">
<td width="20%" align="center">'.date("j M Y, H:i", $death['date']).'</td>
<td> ';
$killers = $db->query("SELECT environment_killers.name AS monster_name, players.name AS player_name, players.deleted AS player_exists FROM killers LEFT JOIN environment_killers ON killers.id = environment_killers.kill_id
LEFT JOIN player_killers ON killers.id = player_killers.kill_id LEFT JOIN players ON players.id = player_killers.player_id
WHERE killers.death_id = '".$death['id']."' ORDER BY killers.final_hit DESC, killers.id ASC")->fetchAll();
$i = 0;
$count = count($killers);
foreach($killers as $killer)
{
$i++;
if($killer['player_name'] != "")
{
if($i == 1)
$dead_add_content .= "Killed at level <b>".$death['level']."</b>";
else if($i == $count)
$dead_add_content .= " and";
else
$dead_add_content .= ",";
$dead_add_content .= " by ";
if($killer['monster_name'] != "")
$dead_add_content .= $killer['monster_name']." summoned by ";
if($killer['player_exists'] == 0)
$dead_add_content .= getPlayerLink($killer['player_name']);
else
$dead_add_content .= $killer['player_name'];
}
else
{
if($i == 1)
$dead_add_content .= "Died at level <b>".$death['level']."</b>";
else if($i == $count)
$dead_add_content .= " and";
else
$dead_add_content .= ",";
$dead_add_content .= " by ".$killer['monster_name'];
}
}
$dead_add_content .= ".</td></tr>";
}
if($number_of_rows > 0)
$dead_add_content += '</table>';
else
$dead_add_content = '';
}
}
else {
$mostdamage = '';
if(fieldExist('mostdamage_by', 'player_deaths'))
$mostdamage = ', `mostdamage_by`, `mostdamage_is_player`, `unjustified`, `mostdamage_unjustified`';
$deaths_db = $db->query('SELECT
`player_id`, `time`, `level`, `killed_by`, `is_player`' . $mostdamage . '
FROM `player_deaths`
WHERE `player_id` = ' . $player->getId() . ' ORDER BY `time` DESC LIMIT 10;');
if(count($deaths_db))
{
$dead_add_content = '<br/><table border=0 cellspacing=1 cellpadding=4 width=100%><tr bgcolor="'.$config['vdarkborder'].'"><td colspan="2" class="white"><b>Character Deaths</b></td></tr>';
$number_of_rows = 0;
foreach($deaths_db as $death)
{
$dead_add_content .= '<tr bgcolor="'.getStyle($number_of_rows++).'">
<td width="20%" align="center">'.date("j M Y, H:i", $death['time']).'</td>
<td> ';
$lasthit = ($death['is_player']) ? getPlayerLink($death['killed_by']) : $death['killed_by'];
$dead_add_content .= 'Killed at level ' . $death['level'] . ' by ' . $lasthit;
if($death['unjustified']) {
$dead_add_content .= " <font color='red' style='font-style: italic;'>(unjustified)</font>";
}
$mostdmg = ($death['mostdamage_by'] !== $death['killed_by']) ? true : false;
if($mostdmg)
{
$mostdmg = ($death['mostdamage_is_player']) ? getPlayerLink($death['mostdamage_by']) : $death['mostdamage_by'];
$dead_add_content .= ' and by ' . $mostdmg;
if ($death['mostdamage_unjustified']) {
$dead_add_content .= " <font color='red' style='font-style: italic;'>(unjustified)</font>";
}
}
else {
$dead_add_content .= " <b>(soloed)</b>";
}
$dead_add_content .= ".</td></tr>";
}
if($number_of_rows > 0)
$dead_add_content += '</table>';
else
$dead_add_content = '';
}
}
$frag_add_content = '';
if($config['characters']['frags'])
{
//frags list by Xampy
$i = 0;
$frags_limit = 10; // frags limit to show? // default: 10
$player_frags = $db->query('SELECT `player_deaths`.*, `players`.`name`, `killers`.`unjustified` FROM `player_deaths` LEFT JOIN `killers` ON `killers`.`death_id` = `player_deaths`.`id` LEFT JOIN `player_killers` ON `player_killers`.`kill_id` = `killers`.`id` LEFT JOIN `players` ON `players`.`id` = `player_deaths`.`player_id` WHERE `player_killers`.`player_id` = '.$player->getId().' ORDER BY `date` DESC LIMIT 0,'.$frags_limit.';');
if(count($player_frags))
{
$frags = 0;
$frag_add_content .= '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><br><TR BGCOLOR='.$config['vdarkborder'].'><TD COLSPAN=2 CLASS=white><B>Victims</B></TD></TR>';
foreach($player_frags as $frag)
{
$frags++;
$frag_add_content .= '<tr bgcolor="' . getStyle($frags) . '">
<td width="20%" align="center">' . date("j M Y, H:i", $frag['date']) . '</td>
<td>Fragged <a href="' . getPlayerLink($frag[name], false) . '">' . $frag[name] . '</a> at level ' . $frag[level];
$frag_add_content .= ". (".(($frag['unjustified'] == 0) ? "<font size=\"1\" color=\"green\">Justified</font>" : "<font size=\"1\" color=\"red\">Unjustified</font>").")</td></tr>";
}
if($frags > 0)
$frag_add_content += '</table>';
else
$frag_add_content = '';
}
}
// signature
if($config['signature_enabled']) {
$signature_url = BASE_URL . 'tools/signature/?name=' . urlencode($player->getName());
if($config['friendly_urls'])
$signature_url = BASE_URL . urlencode($player->getName()) . '.png';
}
$hidden = $player->getCustomField('hidden');
if($hidden != 1) {
// check if account has been banned
$bannedUntil = '';
$banned = array();
if (tableExist('account_bans'))
$banned = $db->query('SELECT `expires_at` as `expires` FROM `account_bans` WHERE `account_id` = ' . $account->getId() . ' and `expires_at` > ' . time());
else if (tableExist('bans')) {
if (fieldExist('expires', 'bans'))
$banned = $db->query('SELECT `expires` FROM `bans` WHERE (`value` = ' . $account->getId() . ' or `value` = ' . $player->getId() . ') and `active` = 1 and `type` != 2 and `type` != 4 and `expires` > ' . time());
else
$banned = $db->query('SELECT `time` as `time` FROM `bans` WHERE (`account` = ' . $account->getId() . ' or `player` = ' . $player->getId() . ') and `type` != 2 and `type` != 4 and `time` > ' . time());
}
foreach ($banned as $ban) {
$bannedUntil = ' <font color="red">[Banished ' . ($ban['expires'] == "-1" ? 'forever' : 'until ' . date("d F Y, h:s", $ban['expires'])) . ']</font>';
}
$account_players = $account->getPlayersList();
$account_players->orderBy('name');
}
echo $twig->render('characters.html.twig', array(
'outfit' => isset($outfit) ? $outfit : null,
'player' => $player,
'account' => $account,
'flag' => $flag,
'oldName' => $oldName,
'sex' => $player_sex,
'marriage_enabled' => $config['characters']['marriage_info'] && fieldExist('marriage', 'players'),
'marital_status' => $marital_status,
'vocation' => $config['vocations'][$player->getVocation()],
'frags_enabled' => $frags_enabled,
'frags_count' => $frags_count,
'town' => isset($config['towns'][$player->getTownId()]) ? $config['towns'][$player->getTownId()] : null,
'house' => array(
'found' => isset($house['id']),
'add' => isset($house['id']) ? $add : null,
'name' => isset($house['id']) ? (isset($house['name']) ? $house['name'] : $house['id']) : null,
'town' => isset($house['town']) ? ' (' . $config['towns'][$house['town']] . ')' : ''
),
'guild' => array(
'rank' => isset($guild_name) ? $rank_of_player->getName() : null,
'link' => isset($guild_name) ? getGuildLink($guild_name) : null
),
'comment' => !empty($comment) ? wordwrap(nl2br($comment), 60, "<br/>", true) : null,
'skills' => isset($skills) ? $skills : null,
'quests_enabled' => $quests_enabled,
'quests' => isset($quests) ? $quests : null,
'equipment' => isset($equipment) ? $equipment : null,
'skull' => $player->getSkullTime() > 0 && ($player->getSkull() == 4 || $player->getSkull() == 5) ? $skulls[$player->getSkull()] : null,
'deaths' => $dead_add_content,
'frags' => $frag_add_content,
'signature_url' => isset($signature_url) ? $signature_url : null,
'player_link' => getPlayerLink($player->getName(), false),
'hidden' => $hidden,
'bannedUntil' => isset($bannedUntil) ? $bannedUntil : null,
'characters_link' => internalLayoutLink('characters'),
'account_players' => isset($account_players) ? $account_players : null,
'search_form' => generate_search_form()
));
}
else
{
$search_errors[] = 'Character <b>' . $name . '</b> does not exist or has been deleted.';
echo $twig->render('error_box.html.twig', array('errors' => $search_errors));
$search_errors = array();
$promotion = '';
if(fieldExist('promotion', 'players'))
$promotion = ', `promotion`';
$deleted = 'deleted';
if(fieldExist('deletion', 'players'))
$deleted = 'deletion';
$query = $db->query('SELECT `name`, `level`, `vocation`' . $promotion . ' FROM `players` WHERE `name` LIKE ' . $db->quote('%' . $name . '%') . ' AND ' . $deleted . ' != 1;');
if($query->rowCount() > 0)
{
echo 'Did you mean:<ul>';
foreach($query as $player) {
if(isset($player['promotion'])) {
if((int)$player['promotion'] > 0)
$player['vocation'] += ($player['promotion'] * $config['vocations_amount']);
}
echo '<li>' . getPlayerLink($player['name']) . ' (<small><strong>level ' . $player['level'] . ', ' . $config['vocations'][$player['vocation']] . '</strong></small>)</li>';
}
echo '</ul>';
}
echo generate_search_form(true);
}
if(!empty($search_errors))
echo $twig->render('error_box.html.twig', array('errors' => $search_errors));
Reload spells.
All records deleted from table myaac_spells in database.
Conjure:
Catchable fatal error: Object of class OTS_DB_MySQL could not be converted to string in E:\xampp\htdocs\system\pages\spells.php on line 72
<?php
/**
* Spells
*
* @package MyAAC
* @author Gesior <[email protected]>
* @author Slawkens <[email protected]>
* @copyright 2017 MyAAC
* @version 0.4.2
* @link http://my-aac.org
*/
defined('MYAAC') or die('Direct access not allowed!');
$title = 'Spells';
$config_vocations = $config['vocations'];
$canEdit = hasFlag(FLAG_CONTENT_SPELLS) || admin();
if(isset($_POST['reload_spells']) && $canEdit)
{
try { $db->query('DELETE FROM ' . TABLE_PREFIX . 'spells WHERE 1 = 1'); } catch(PDOException $error) {}
echo '<h2>Reload spells.</h2>';
echo '<h2>All records deleted from table <b>' . TABLE_PREFIX . 'spells</b> in database.</h2>';
foreach($config_vocations as $voc_id => $voc_name) {
$vocations_ids[$voc_name] = $voc_id;
}
$allspells = new OTS_SpellsList($config['data_path'].'spells/spells.xml');
//add conjure spells
$conjurelist = $allspells->getConjuresList();
echo "<h3>Conjure:</h3>";
foreach($conjurelist as $spellname) {
$spell = $allspells->getConjure($spellname);
$lvl = $spell->getLevel();
$mlvl = $spell->getMagicLevel();
$mana = $spell->getMana();
$name = $spell->getName();
$soul = $spell->getSoul();
$spell_txt = $spell->getWords();
$vocations = $spell->getVocations();
$nr_of_vocations = count($vocations);
$vocations_to_db = "";
$voc_nr = 0;
foreach($vocations as $vocation_to_add) {
if(check_number($vocation_to_add)) {
$vocations_to_db .= $vocation_to_add;
}
else
$vocations_to_db .= $vocations_ids[$vocation_to_add];
$voc_nr++;
if($voc_nr != $nr_of_vocations) {
$vocations_to_db .= ',';
}
}
$enabled = $spell->isEnabled();
if($enabled) {
$hide_spell = 0;
}
else {
$hide_spell = 1;
}
$pacc = $spell->isPremium();
if($pacc) {
$pacc = '1';
}
else {
$pacc = '0';
}
$type = 2;
$count = $spell->getConjureCount();
try {
$db->query('INSERT INTO myaac_spells (spell, name, words, type, mana, level, maglevel, soul, premium, vocations, conjure_count, hidden) VALUES (' . $db->quote($spell_txt) . ', ' . $db-quote($name) . ', ' . $db->quote($spell_txt) , ', ' . $db->quote($type) . ', ' . $db->quote($mana) . ', ' . $db->quote($lvl) . ', ' . $db->quote($mlvl) . ', ' . $db->quote($soul) . ', ' . $db>quote($pacc) . ', ' . $db->quote($vocations_to_db) . ', ' . $db->quote($count) . ', ' . $db->quote($hide_spell) . ')');
success("Added: " . $name . "<br>");
}
catch(PDOException $error) {
warning('Error while adding spell (' . $name . '): ' . $error->getMessage());
}
}
//add instant spells
$instantlist = $allspells->getInstantsList();
echo "<h3>Instant:</h3>";
foreach($instantlist as $spellname) {
$spell = $allspells->getInstant($spellname);
$lvl = $spell->getLevel();
$mlvl = $spell->getMagicLevel();
$mana = $spell->getMana();
$name = $spell->getName();
$soul = $spell->getSoul();
$spell_txt = $spell->getWords();
if(strpos($spell_txt, '###') !== false)
continue;
$vocations = $spell->getVocations();
$nr_of_vocations = count($vocations);
$vocations_to_db = "";
$voc_nr = 0;
foreach($vocations as $vocation_to_add) {
if(check_number($vocation_to_add)) {
$vocations_to_db .= $vocation_to_add;
}
else
$vocations_to_db .= $vocations_ids[$vocation_to_add];
$voc_nr++;
if($voc_nr != $nr_of_vocations) {
$vocations_to_db .= ',';
}
}
$enabled = $spell->isEnabled();
if($enabled) {
$hide_spell = 0;
}
else {
$hide_spell = 1;
}
$pacc = $spell->isPremium();
if($pacc) {
$pacc = '1';
}
else {
$pacc = '0';
}
$type = 1;
$count = 0;
try {
$db->query("INSERT INTO myaac_spells (spell, name, words, type, mana, level, maglevel, soul, premium, vocations, conjure_count, hidden) VALUES (".$db->quote($spell_txt).", ".$db->quote($name).", ".$db->quote($spell_txt).", '".$type."', '".$mana."', '".$lvl."', '".$mlvl."', '".$soul."', '".$pacc."', '".$vocations_to_db."', '".$count."', '".$hide_spell."')");
success("Added: ".$name."<br/>");
}
catch(PDOException $error) {
warning('Error while adding spell (' . $name . '): ' . $error->getMessage());
}
}
}
if($canEdit)
{
?>
<form method="post" action="index.php?subtopic=spells">
<input type="hidden" name="reload_spells" value="yes"/>
<input type="submit" value="(admin) Reload spells"/>
</form>
<?php
}
$vocation_id = (int) (isset($_REQUEST['vocation_id']) ? $_REQUEST['vocation_id'] : 'All');
$order = 'spell';
if(isset($_GET['order']))
$order = $_GET['order'];
if(!in_array($order, array('spell', 'words', 'type', 'mana', 'level', 'maglevel', 'soul')))
$order = 'level';
?>
<form action="?subtopic=spells" method="post">
<table border="0" cellspacing="1" cellpadding="4" width="100%">
<tr bgcolor="<?php echo $config['vdarkborder']; ?>">
<td class="white"><b>Spell Search</b></td>
</tr>
<tr bgcolor="<?php echo $config['darkborder']; ?>">
<td>Only for vocation: <select name="vocation_id">
<option value="All" <?php
if('All' == $vocation_id)
echo 'SELECTED';
echo '>All';
foreach($config_vocations as $id => $vocation)
{
echo '<option value="' . $id . '" ';
if($id == $vocation_id && $vocation_id != "All" && $vocation_id != '')
echo 'SELECTED';
echo '>' . $vocation;
}
?>
</select>
<input type="hidden" name="order" value="<?php echo $order; ?>"> <input type="image" name="Submit" alt="Submit" src="<?php echo $template_path; ?>/images/buttons/sbutton_submit.gif" border="0" width="120" height="18">
</td>
</tr>
</table>
</form>
<table border="0" cellspacing="1" cellpadding="4" width="100%">
<tr bgcolor="<?php echo $config['vdarkborder']; ?>">
<td class="white">
<b><a href="?subtopic=spells&vocation_id=<?php echo $vocation_id; ?>&order=spell"><font class="white">Name</font></a></b>
</td>
<td class="white">
<b><a href="?subtopic=spells&vocation_id=<?php echo $vocation_id; ?>&order=words"><font class="white">Words</font></a></b>
</td>
<td class="white">
<b><a href="?subtopic=spells&vocation_id=<?php echo $vocation_id; ?>&order=type"><font class="white">Type<br/>(count)</font></a></b>
</td>
<td class="white">
<b><a href="?subtopic=spells&vocation_id=<?php echo $vocation_id; ?>&order=mana"><font class="white">Mana</font></a></b>
</td>
<td class="white">
<b><a href="?subtopic=spells&vocation_id=<?php echo $vocation_id; ?>&order=level"><font class="white">Level</font></a></b>
</td>
<td class="white">
<b><a href="?subtopic=spells&vocation_id=<?php echo $vocation_id; ?>&order=maglevel"><font class="white">Magic<br/>Level</font></a></b>
</td>
<td class="white">
<b><a href="?subtopic=spells&vocation_id=<?php echo $vocation_id; ?>&order=soul"><font class="white">Soul</font></a></b>
</td>
<td class="white">
<b>Premium</b>
</td>
<td class="white">
<b>Vocations:</b>
</td>
</tr>
<?php
$i = 0;
$spells = $db->query('SELECT * FROM ' . $db->tableName(TABLE_PREFIX . 'spells') . ' WHERE ' . $db->fieldName('hidden') . ' != 1 ORDER BY ' . $order . ', level');
if(isset($vocation_id) && $vocation_id != 'All' && $vocation_id != '')
{
foreach($spells as $spell)
{
$spell_vocations = explode(",", $spell['vocations']);
if(in_array($vocation_id, $spell_vocations) || empty($spell['vocations']))
{
echo '<TR BGCOLOR="' . getStyle(++$i) . '"><TD>' . $spell['name'] . '</TD><TD>' . $spell['words'] . '</TD>';
if($spell['type'] == 2)
echo '<TD>Conjure ('.$spell['conjure_count'].')</TD>';
else
echo '<TD>Instant</TD>';
echo '<TD>' . $spell['mana'] . '</TD><TD>' . $spell['level'] . '</TD><TD>' . $spell['maglevel'] . '</TD><TD>' . $spell['soul'] . '</TD><TD>' . ($spell ['premium'] == 1 ? 'yes' : 'no') . '</TD><TD>' . $config_vocations[$vocation_id] . '</TD></TR>';
}
}
}
else
{
foreach($spells as $spell)
{
$spell_vocations = explode(",", $spell['vocations']);
echo '<TR BGCOLOR="' . getStyle(++$i) . '"><TD>' .$spell['name'] . '</TD><TD>' . $spell['words'] . '</TD>';
if($spell['type'] == 1)
echo '<TD>Instant</TD>';
else
echo '<TD>Conjure ('.$spell['conjure_count'].')</TD>';
echo '<TD>' . $spell['mana'] . '</TD><TD>' . $spell['level'] . '</TD><TD>' . $spell['maglevel'] . '</TD><TD>' . $spell['soul'] . '</TD><TD>'. ($spell ['premium'] == 1 ? 'yes' : 'no') .'</TD><TD><font size="1">';
$showed_vocations = 0;
foreach($spell_vocations as $spell_vocation)
{
if(isset($config_vocations[$spell_vocation])) {
echo $config_vocations[$spell_vocation];
$showed_vocations++;
}
if($showed_vocations != count($spell_vocations))
echo '<br/>';
}
echo '</font></TD></TR>';
}
}
?>
</table>
Hello! I have choosen to yse MyAAC and almost everything works, the one thing i have found out is when i search for a character i get this error.
Code:Fatal error: An iterator cannot be used with foreach by reference in E:\xampp\htdocs\system\pages\characters.php on line 169
And this is mu characters.php
PHP:<?php /** * Characters * * @package MyAAC * @author Gesior <[email protected]> * @author Slawkens <[email protected]> * @copyright 2017 MyAAC * @version 0.4.2 * @link http://my-aac.org */ defined('MYAAC') or die('Direct access not allowed!'); $title = 'Characters'; require(SYSTEM . 'item.php'); $groups = new OTS_Groups_List(); function generate_search_form($autofocus = false) { global $config, $twig; return $twig->render('characters.form.html.twig', array( 'link' => getPageLink('characters'), 'vdarkborder' => $config['vdarkborder'], 'darkborder' => $config['darkborder'], 'autofocus' => $autofocus )); } function retrieve_former_name($name) { global $oldName, $db; if(tableExist('player_namelocks') && fieldExist('name', 'player_namelocks')) { $newNameSql = $db->query('SELECT `name`, `new_name` FROM `player_namelocks` WHERE `name` = ' . $db->quote($name)); if($newNameSql->rowCount() > 0) // namelocked { $newNameSql = $newNameSql->fetch(); $oldName = ' (<small><b>Former name:</b> ' . $newNameSql['name'] . '</small>)'; return $newNameSql['new_name']; } } return ''; } $name = ''; if(isset($_REQUEST['name'])) $name = stripslashes(ucwords(strtolower(trim($_REQUEST['name'])))); if(empty($name)) { $tmp_link = getPlayerLink($name); echo 'Here you can get detailed information about a certain player on ' . $config['lua']['serverName'] . '.<BR>'; echo generate_search_form(true); return; } $name = str_replace('/', '', $name); $oldName = ''; $player = $ots->createObject('Player'); $player->find($name); if(!$player->isLoaded()) { $tmp_zmienna = ""; $tmp_name = retrieve_former_name($name); while(!empty($tmp_name)) { $tmp_zmienna = $tmp_name; $tmp_name = retrieve_former_name($tmp_zmienna); } if(!empty($tmp_zmienna)) $player->find($tmp_zmienna); } if($player->isLoaded() && !$player->isDeleted()) { $title = $player->getName() . ' - ' . $title; $account = $player->getAccount(); $rows = 0; if($config['characters']['outfit']) $outfit = $config['outfit_images_url'] . '?id=' . $player->getLookType() . (fieldExist('lookaddons', 'players') ? '&addons=' . $player->getLookAddons() : '') . '&head=' . $player->getLookHead() . '&body=' . $player->getLookBody() . '&legs=' . $player->getLookLegs() . '&feet=' . $player->getLookFeet(); $flag = ''; if($config['account_country']) $flag = getFlagImage($account->getCustomField('country')); $player_sex = 'Unknown'; if(isset($config['genders'][$player->getSex()])) $player_sex = strtolower($config['genders'][$player->getSex()]); $marriage = new OTS_Player(); $marriage->load($player->getMarriage()); $marital_status = 'single'; if($marriage->isLoaded()) $marital_status = 'married to ' . getPlayerLink($marriage->getName()); $frags_enabled = tableExist('player_killers') && $config['characters']['frags']; $frags_count = 0; if($frags_enabled) { $query = $db->query( 'SELECT COUNT(`player_id`) as `frags`' . 'FROM `player_killers`' . 'WHERE `player_id` = ' .$player->getId() . ' ' . 'GROUP BY `player_id`' . 'ORDER BY COUNT(`player_id`) DESC'); if($query->rowCount() > 0) { $query = $query->fetch(); $frags_count = $query['frags']; } } $town_field = 'town'; if(fieldExist('town_id', 'houses')) $town_field = 'town_id'; else if(fieldExist('townid', 'houses')) $town_field = 'townid'; else if(!fieldExist('town', 'houses')) $town_field = false; if(fieldExist('name', 'houses')) { $house = $db->query('SELECT `id`, `paid`, `name`' . ($town_field != false ? ', `' . $town_field . '` as `town`' : '') . ' FROM `houses` WHERE `owner` = '.$player->getId())->fetch(); if(isset($house['id'])) { $add = ''; if($house['paid'] > 0) $add = ' is paid until '.date("M d Y", $house['paid']); } } $rank_of_player = $player->getRank(); if($rank_of_player->isLoaded()) { $guild = $rank_of_player->getGuild(); if($guild->isLoaded()) { $guild_name = $guild->getName(); } } $comment = $player->getComment(); if($config['characters']['skills']) { if(fieldExist('skill_fist', 'players')) {// tfs 1.0+ $skills_db = $db->query('SELECT `skill_fist`, `skill_club`, `skill_sword`, `skill_axe`, `skill_dist`, `skill_shielding`, `skill_fishing` FROM `players` WHERE `id` = ' . $player->getId())->fetch(); $skill_ids = array( POT::SKILL_FIST => 'skill_fist', POT::SKILL_CLUB => 'skill_club', POT::SKILL_SWORD => 'skill_sword', POT::SKILL_AXE => 'skill_axe', POT::SKILL_DIST => 'skill_dist', POT::SKILL_SHIELD => 'skill_shielding', POT::SKILL_FISH => 'skill_fishing', ); $skills = array(); foreach($skill_ids as $skillid => $field_name) { $skills[] = array('skillid' => $skillid, 'value' => $skills_db[$field_name]); } } else $skills = $db->query('SELECT `skillid`, `value` FROM `player_skills` WHERE `player_id` = ' . $player->getId() . ' LIMIT 7'); foreach($skills as &$skill) { $skill['name'] = getSkillName($skill['skillid']); } } $quests_enabled = $config['characters']['quests'] && !empty($config['quests']); if($quests_enabled) { $quests = $config['quests']; $sql_query_in = ''; $i = 0; foreach($quests as $quest_name => $quest_storage) { if($i != 0) $sql_query_in .= ', '; $sql_query_in .= $quest_storage; $i++; } $storage_sql = $db->query('SELECT `key`, `value` FROM `player_storage` WHERE `player_id` = '.$player->getId().' AND `key` IN (' . $sql_query_in . ')'); $player_storage = array(); foreach($storage_sql as $storage) $player_storage[$storage['key']] = $storage['value']; foreach($quests as &$storage) { $storage = isset($player_storage[$storage]) && $player_storage[$storage] > 0; } } if($config['characters']['equipment']) { global $db; $eq_sql = $db->query('SELECT `pid`, `itemtype` FROM player_items WHERE player_id = '.$player->getId().' AND (`pid` >= 1 and `pid` <= 10)'); $equipment = array(); foreach($eq_sql as $eq) $equipment[$eq['pid']] = $eq['itemtype']; $empty_slots = array("", "no_helmet", "no_necklace", "no_backpack", "no_armor", "no_handleft", "no_handright", "no_legs", "no_boots", "no_ring", "no_ammo"); for($i = 0; $i <= 10; $i++) { if(!isset($equipment[$i]) || $equipment[$i] == 0) $equipment[$i] = $empty_slots[$i]; } for($i = 1; $i < 11; $i++) { if(check_number($equipment[$i])) $equipment[$i] = getItemImage($equipment[$i]); else $equipment[$i] = '<img src="images/items/' . $equipment[$i] . '.gif" width="32" height="32" border="0" alt=" ' . $equipment[$i] . '" />'; } $skulls = array( 1 => 'yellow_skull', 2 => 'green_skull', 3 => 'white_skull', 4 => 'red_skull', 5 => 'black_skull' );
foreach($skills as &$skill) {
foreach($skills as $skill) {
Same when im gonna import the spells. i get this error aswell
HTML:Reload spells. All records deleted from table myaac_spells in database. Conjure: Catchable fatal error: Object of class OTS_DB_MySQL could not be converted to string in E:\xampp\htdocs\system\pages\spells.php on line 72
And this is my spells.php
PHP:<?php /** * Spells * * @package MyAAC * @author Gesior <[email protected]> * @author Slawkens <[email protected]> * @copyright 2017 MyAAC * @version 0.4.2 * @link http://my-aac.org */ defined('MYAAC') or die('Direct access not allowed!'); $title = 'Spells'; $config_vocations = $config['vocations']; $canEdit = hasFlag(FLAG_CONTENT_SPELLS) || admin(); if(isset($_POST['reload_spells']) && $canEdit) { try { $db->query('DELETE FROM ' . TABLE_PREFIX . 'spells WHERE 1 = 1'); } catch(PDOException $error) {} echo '<h2>Reload spells.</h2>'; echo '<h2>All records deleted from table <b>' . TABLE_PREFIX . 'spells</b> in database.</h2>'; foreach($config_vocations as $voc_id => $voc_name) { $vocations_ids[$voc_name] = $voc_id; } $allspells = new OTS_SpellsList($config['data_path'].'spells/spells.xml'); //add conjure spells $conjurelist = $allspells->getConjuresList(); echo "<h3>Conjure:</h3>"; foreach($conjurelist as $spellname) { $spell = $allspells->getConjure($spellname); $lvl = $spell->getLevel(); $mlvl = $spell->getMagicLevel(); $mana = $spell->getMana(); $name = $spell->getName(); $soul = $spell->getSoul(); $spell_txt = $spell->getWords(); $vocations = $spell->getVocations(); $nr_of_vocations = count($vocations); $vocations_to_db = ""; $voc_nr = 0; foreach($vocations as $vocation_to_add) { if(check_number($vocation_to_add)) { $vocations_to_db .= $vocation_to_add; } else $vocations_to_db .= $vocations_ids[$vocation_to_add]; $voc_nr++; if($voc_nr != $nr_of_vocations) { $vocations_to_db .= ','; } } $enabled = $spell->isEnabled(); if($enabled) { $hide_spell = 0; } else { $hide_spell = 1; } $pacc = $spell->isPremium(); if($pacc) { $pacc = '1'; } else { $pacc = '0'; } $type = 2; $count = $spell->getConjureCount(); try { $db->query('INSERT INTO myaac_spells (spell, name, words, type, mana, level, maglevel, soul, premium, vocations, conjure_count, hidden) VALUES (' . $db->quote($spell_txt) . ', ' . $db-quote($name) . ', ' . $db->quote($spell_txt) , ', ' . $db->quote($type) . ', ' . $db->quote($mana) . ', ' . $db->quote($lvl) . ', ' . $db->quote($mlvl) . ', ' . $db->quote($soul) . ', ' . $db>quote($pacc) . ', ' . $db->quote($vocations_to_db) . ', ' . $db->quote($count) . ', ' . $db->quote($hide_spell) . ')'); success("Added: " . $name . "<br>"); } catch(PDOException $error) { warning('Error while adding spell (' . $name . '): ' . $error->getMessage()); } } //add instant spells $instantlist = $allspells->getInstantsList(); echo "<h3>Instant:</h3>"; foreach($instantlist as $spellname) { $spell = $allspells->getInstant($spellname); $lvl = $spell->getLevel(); $mlvl = $spell->getMagicLevel(); $mana = $spell->getMana(); $name = $spell->getName(); $soul = $spell->getSoul(); $spell_txt = $spell->getWords(); if(strpos($spell_txt, '###') !== false) continue; $vocations = $spell->getVocations(); $nr_of_vocations = count($vocations); $vocations_to_db = ""; $voc_nr = 0; foreach($vocations as $vocation_to_add) { if(check_number($vocation_to_add)) { $vocations_to_db .= $vocation_to_add; } else $vocations_to_db .= $vocations_ids[$vocation_to_add]; $voc_nr++; if($voc_nr != $nr_of_vocations) { $vocations_to_db .= ','; } } $enabled = $spell->isEnabled(); if($enabled) { $hide_spell = 0; } else { $hide_spell = 1; } $pacc = $spell->isPremium(); if($pacc) { $pacc = '1'; } else { $pacc = '0'; } $type = 1; $count = 0; try { $db->query("INSERT INTO myaac_spells (spell, name, words, type, mana, level, maglevel, soul, premium, vocations, conjure_count, hidden) VALUES (".$db->quote($spell_txt).", ".$db->quote($name).", ".$db->quote($spell_txt).", '".$type."', '".$mana."', '".$lvl."', '".$mlvl."', '".$soul."', '".$pacc."', '".$vocations_to_db."', '".$count."', '".$hide_spell."')"); success("Added: ".$name."<br/>"); } catch(PDOException $error) { warning('Error while adding spell (' . $name . '): ' . $error->getMessage()); } }
Post me your spells.xml file.
This is my spells.xml and also GREAT JOB!
(Could not post it because it was more the 25 000 letters long)