Git Product home page Git Product logo

myaac-plugins's People

Contributors

slawkens avatar xitobuh avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

majestyotbr otbr

myaac-plugins's Issues

/?gifts not working

image

my page ?gifts is not rendering gifts.html.twig.
it only shows gift-header.html.twig.
i also found out there is another gifts.php on /gesior-shop-system/pages. slightly difference oon line 14, the file on gesior has
csrfProtect(); , when applied to my ''system'' gift page, it comes back with http500.

Any idea?

CODE gifts.php on html/system/pages:
`<?php
/**

require_once(PLUGINS . 'gesior-shop-system/libs/shop-system.php');
require_once(PLUGINS . 'gesior-shop-system/config.php');

if(!$config['gifts_system']) {
if(!admin()) {
$errors[] = 'The gifts system is disabled.';
$twig->display('error_box.html.twig', array('errors' => $errors));
return;
} else {
warning("You're able to access this page but it is disabled for normal users.

Its enabled for you so you can view/edit shop offers before displaying them to users.

You can enable it by editing this line in myaac config.local.php file:

<p style="margin-left: 3em;">$config['gifts_system'] = true;

");
}
}

if(GesiorShop::getDonationType() == 'coins' && !fieldExist('coins', 'accounts')) {
$errors[] = "Your server doesn't support accounts.coins. Please change back config.donation_type to points.";
$twig->display('error_box.html.twig', array('errors' => $errors));
return;
}

if($logged) {
$user_premium_points = $account_logged->getCustomField(GesiorShop::getDonationType());
} else {
$was_before = $config['friendly_urls'];
$config['friendly_urls'] = true;
$user_premium_points = generateLink(getLink('?subtopic=accountmanagement') . '&redirect=' . urlencode(BASE_URL . '?subtopic=gifts'), 'Login first');
$config['friendly_urls'] = $was_before;
}

if(!empty($action)) {
$errors = array();
if(!$logged || !$account_logged->isLoaded()) {
$errors[] = 'Please login first';
$twig->display('error_box.html.twig', array('errors' => $errors));
return;
}

switch ($action) {
	case 'select_player':
		$buy_id = isset($_REQUEST['buy_id']) ? (int)$_REQUEST['buy_id'] : null;
		if(empty($buy_id)) {
			$errors[] = 'Please <a href="?subtopic=gifts">select item</a> first.';
			break;
		}

		$buy_offer = GesiorShop::getOfferById($buy_id);
		if(!isset($buy_offer['id']) || $buy_offer['hidden'] == '1') {
			$errors[] = 'Offer with ID <b>' . $buy_id . '</b> doesn\'t exist. Please <a href="?subtopic=gifts">select item</a> again.';
			break;
		}

		if($user_premium_points < $buy_offer['points']) {
			$errors[] = 'For this item you need <b>' . $buy_offer['points'] . '</b> points. You have only <b>' . $user_premium_points . '</b> premium points. Please <a href="?subtopic=gifts">select other item</a> or buy premium points.';
			break;
		}

		GesiorShop::selectPlayerAction($account_logged, $buy_id, $buy_offer, $user_premium_points);
		break;

	case 'confirm_transaction':
		$buy_id = isset($_POST['buy_id']) ? (int)$_POST['buy_id'] : null;
		if(empty($buy_id)) {
			$errors[] = 'Please <a href="?subtopic=gifts">select item</a> first.';
			break;
		}

		$buy_offer = GesiorShop::getOfferById($buy_id);
		if(!isset($buy_offer['id']) || $buy_offer['hidden'] == '1') {
			$errors[] = 'Offer with ID <b>' . $buy_id . '</b> doesn\'t exist. Please <a href="?subtopic=gifts">select item</a> again.';
			break;
		}

		$buy_from = isset($_POST['buy_from']) ? stripslashes(urldecode($_POST['buy_from'])) : '';
		if(empty($buy_from)) {
			$buy_from = 'Anonymous';
		}

		if(!check_name($buy_from)) {
			$errors[] = 'Invalid nick ("from player") format. Please <a href="?subtopic=gifts&action=select_player&buy_id=' . $buy_id . '">select other name</a> or contact with administrator.';
			break;
		}

		$buy_name = isset($_POST['buy_name']) ? stripslashes(urldecode($_POST['buy_name'])) : '';
		if(!check_name($buy_name)) {
			$errors[] = 'Invalid name format. Please <a href="?subtopic=gifts&action=select_player&buy_id=' . $buy_id . '">select other name</a> or contact with administrator.';
			break;
		}

		if($user_premium_points < $buy_offer['points']) {
			$errors[] = 'For this item you need <b>' . $buy_offer['points'] . '</b> points. You have only <b>' . $user_premium_points . '</b> premium points. Please <a href="?subtopic=gifts">select other item</a> or buy premium points.';
			break;
		}

		$buy_player = new OTS_Player();
		$buy_player->find($buy_name);
		if(!$buy_player->isLoaded()) {
			$errors[] = 'Player with name <b>' . $buy_name . '</b> doesn\'t exist. Please <a href="?subtopic=gifts&action=select_player&buy_id=' . $buy_id . '">select other name</a>.';
			break;
		}

		if ($buy_player->isDeleted()) {
			$errors[] = 'Player with name <b>' . $buy_name . '</b> has been deleted. Please <a href="?subtopic=gifts&action=select_player&buy_id=' . $buy_id . '">select other name</a>.';
			break;
		}

		GesiorShop::confirmTransactionAction($account_logged, $buy_player, $buy_id, $buy_offer, $buy_from, $buy_name, $user_premium_points, $errors);
		break;

	case 'show_history':
		GesiorShop::showHistoryAction($account_logged);
		break;
}

if(!empty($errors)) {
	$twig->display('error_box.html.twig', array('errors' => $errors));
}

} else {
unset($_SESSION['viewed_confirmation_page']);

$offer_categories = array();
$tmp_query = $db->query('SELECT `id`, `name` FROM `' . 'z_shop_categories` WHERE `hidden` != 1')
	->fetchAll();
foreach($tmp_query as $tmp_res) {
	$offer_categories[$tmp_res['id']] = $tmp_res['name'];
}

$get_offer_category = $_GET['offercat'] ?? 1;
$tmp = '';
if($cache->enabled() && $cache->fetch('mounts', $tmp)) {
	$config['mounts'] = unserialize($tmp);
} else {
	$mounts = new DOMDocument();
	$file = $config['data_path'] . 'XML/mounts.xml';
	if (file_exists($file)) {
		$mounts->load($file);
		if ($mounts) {
			$config['mounts'] = array();
			foreach ($mounts->getElementsByTagName('mount') as $mount) {
				$id = $mount->getAttribute('id');
				$config['mounts'][$id] = $mount->getAttribute('clientid');
			}
			if ($cache->enabled()) {
				$cache->set('mounts', serialize($config['mounts']), 120);
			}
		}
	}
}

$offers_fetch = array();
$tmp = null;
if($cache->enabled() && $cache->fetch('shop_offers_fetch', $tmp)) {
	$offers_fetch = unserialize($tmp);
} else {
	$offers_fetch = GesiorShop::getOffers();

	if($cache->enabled()) {
		$cache->set('shop_offers_fetch', serialize($offers_fetch), 120);
	}
}

if (isset($_REQUEST['success'])) {
	$twig->display('gesior-shop-system/templates/success.html.twig');
}

if (isset($_REQUEST['cancel'])) {
	$twig->display('gesior-shop-system/templates/cancel.html.twig');
}

$twig->display('gesior-shop-system/templates/gifts-header.html.twig', [
	'user_premium_points' => $user_premium_points,
]);

if (config('enable_most_popular_items')) {
	$twig->display('gesior-shop-system/templates/most-popular.html.twig', [
		'offers' => GesiorShop::getMostPopular(),
	]);
}

$twig->display('gesior-shop-system/templates/gifts.html.twig', array(
	'title' => $title,
	'logged' => !empty($logged) ? $logged : false,
	'user_premium_points' => $user_premium_points,
	'offer_categories' => $offer_categories,
	'offers_fetch' => $offers_fetch,
	'get_offer_category' => $get_offer_category,
	'outfit_colors' => $config['shop_outfit_colors'],
));

}
`

CODE /html/plugins/gesior-shop-system/templates/gifts.html.twig:
`

<title>Gifts</title>
{% if warning is defined %}

{{ warning }}

{% endif %}
{% for id, name in offer_categories %}
    <a class="offer_type" href="{{ getLink('gifts') }}?offercat={{ id }}" {% if get_offer_category == id %} style="background-color: #505050;"{% endif %}>
        {{ name }}
    </a>
{% endfor %}

<table class="offer_table">
    <tr>
        <th>Picture</th>
        <th>Description</th>
        <th>Points</th>
        <th>Select product</th>
    </tr>

    {% if offers_fetch|length > 0 %}
        {% for offer in offers_fetch if offer.category_id == get_offer_category %}
            <tr>
                <td>{{ offer.images|raw }}</td>
                <td style="text-align: left">{{ offer.name }}<br/>{{ offer.description|raw }}</td>
                <td>{{ offer.points }}</td>
                <td>
                    {% if logged %}
                        <form action="{{ getLink('gifts') }}?action=select_player" method="post">
                            {{ csrf() }}
                            <input type="hidden" name="buy_id" value="{{ offer.id }}">
                            <input type="submit" value="Buy">
                        </form>
                    {% else %}
                        <b>Login to buy</b>
                    {% endif %}
                </td>
            </tr>
        {% endfor %}
    {% else %}
        <tr>
            <td colspan="4" style="text-align: left">There are no offers here.</td>
        </tr>
    {% endif %}
</table>
`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.