Skip to content

Commit

Permalink
https://github.com/rusefi/rusefi/issues/3790
Browse files Browse the repository at this point in the history
  • Loading branch information
rusefillc committed Jan 15, 2022
1 parent 3760057 commit fc15e3e
Show file tree
Hide file tree
Showing 5 changed files with 545 additions and 0 deletions.
63 changes: 63 additions & 0 deletions www/forum/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#
# Uncomment the statement below if you want to make use of
# HTTP authentication and it does not already work.
# This could be required if you are for example using PHP via Apache CGI.
#
#<IfModule mod_rewrite.c>
#RewriteEngine on
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule .* https://rusefi.com%{REQUEST_URI} [R,L]
</IfModule>

# With Apache 2.4 the "Order, Deny" syntax has been deprecated and moved from
# module mod_authz_host to a new module called mod_access_compat (which may be
# disabled) and a new "Require" syntax has been introduced to mod_authz_host.
# We could just conditionally provide both versions, but unfortunately Apache
# does not explicitly tell us its version if the module mod_version is not
# available. In this case, we check for the availability of module
# mod_authz_core (which should be on 2.4 or higher only) as a best guess.
<IfModule mod_version.c>
<IfVersion < 2.4>
<Files "config.php">
Order Allow,Deny
Deny from All
</Files>
<Files "common.php">
Order Allow,Deny
Deny from All
</Files>
</IfVersion>
<IfVersion >= 2.4>
<Files "config.php">
Require all denied
</Files>
<Files "common.php">
Require all denied
</Files>
</IfVersion>
</IfModule>
<IfModule !mod_version.c>
<IfModule !mod_authz_core.c>
<Files "config.php">
Order Allow,Deny
Deny from All
</Files>
<Files "common.php">
Order Allow,Deny
Deny from All
</Files>
</IfModule>
<IfModule mod_authz_core.c>
<Files "config.php">
Require all denied
</Files>
<Files "common.php">
Require all denied
</Files>
</IfModule>
</IfModule>
208 changes: 208 additions & 0 deletions www/forum/ext/ernadoo/qte/event/main_listener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
<?php
/**
*
* @package Quick Title Edition Extension
* @copyright (c) 2015 ABDev
* @copyright (c) 2015 PastisD
* @copyright (c) 2015 Geolim4 <http://geolim4.com>
* @copyright (c) 2015 Zoddo <zoddo.ino@gmail.com>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/

namespace ernadoo\qte\event;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class main_listener implements EventSubscriberInterface
{
/** @var \phpbb\request\request */
protected $request;

/** @var \phpbb\template\template */
protected $template;

/** @var \phpbb\user */
protected $user;

/** @var \phpbb\log\log */
protected $log;

/** @var \ernadoo\qte\qte */
protected $qte;

public function __construct(\phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, \phpbb\log\log $log, \ernadoo\qte\qte $qte)
{
$this->request = $request;
$this->template = $template;
$this->user = $user;
$this->log = $log;
$this->qte = $qte;
}

static public function getSubscribedEvents()
{
return array(
// viewforum
'core.viewforum_modify_topics_data' => 'viewforum_get_user_infos',
'core.viewforum_modify_topicrow' => 'viewforum_assign_topic_attributes',

// viewtopic
'core.viewtopic_add_quickmod_option_before' => 'viewtopic_attr_apply',
'core.viewtopic_assign_template_vars_before' => 'viewtopic_select_assign_attributes',
'core.viewtopic_modify_page_title' => 'viewtopic_attr_title',

// posting
'core.posting_modify_template_vars' => 'posting_select_assign_attributes',
'core.posting_modify_submission_errors' => 'posting_check_attribute',
'core.posting_modify_submit_post_before' => 'posting_submit_data',
'core.submit_post_modify_sql_data' => 'posting_save_attribute',
);
}

public function viewforum_assign_topic_attributes($event)
{
if (!empty($event['row']['topic_attr_id']))
{
$topic_row = $event['topic_row'];
$topic_row['TOPIC_ATTRIBUTE'] = $this->qte->attr_display($event['row']['topic_attr_id'], $event['row']['topic_attr_user'], $event['row']['topic_attr_time']);
$event['topic_row'] = $topic_row;
}
}

public function viewforum_get_user_infos($event)
{
if (sizeof($event['topic_list']))
{
$this->qte->get_users_by_topic_id($event['topic_list']);
}
}

public function viewtopic_attr_title($event)
{
$attr_title = $this->qte->attr_title($event['topic_data']['topic_attr_id'], $event['topic_data']['topic_attr_user'], $event['topic_data']['topic_attr_time']);
$event['page_title'] = $attr_title ? $attr_title . ' ' . $event['page_title'] : $event['page_title'];
}

public function viewtopic_select_assign_attributes($event)
{
if (!empty($event['topic_data']['topic_attr_id']))
{
$this->qte->get_users_by_topic_id(array($event['topic_data']['topic_id']));
$this->template->assign_var('TOPIC_ATTRIBUTE', $this->qte->attr_display($event['topic_data']['topic_attr_id'], $event['topic_data']['topic_attr_user'], $event['topic_data']['topic_attr_time']));
}

$this->qte->attr_select($event['forum_id'], $event['topic_data']['topic_poster'], (int) $event['topic_data']['topic_attr_id'], $event['viewtopic_url']);
}

public function viewtopic_attr_apply($event)
{
$attr_id = (int) $this->request->variable('attr_id', 0);
if ($attr_id)
{
$this->qte->get_users_by_user_id($this->user->data['user_id']);
$this->qte->attr_apply($attr_id, $event['topic_id'], $event['forum_id'], $event['topic_data']['topic_attr_id'], $event['topic_data']['topic_poster'], $event['viewtopic_url']);
}
}

public function posting_select_assign_attributes($event)
{
$topic_attribute = $this->request->variable('attr_id', !empty($event['post_data']['topic_attr_id']) ? \ernadoo\qte\qte::KEEP : 0, false, \phpbb\request\request_interface::POST);

# old line $this->qte->attr_select($event['forum_id'], !empty($event['post_data']['topic_attr_user']) ? $event['post_data']['topic_attr_user'] : 0, (int) $topic_attribute, '', $event['mode']);
# custom version see https://github.com/rusefi/rusefi/issues/556
$this->qte->attr_select($event['forum_id'], !empty($event['post_data']['topic_poster']) ? $event['post_data']['topic_poster'] : 0, (int) $topic_attribute, '', $event['mode']);

if ($event['mode'] != 'post')
{
$post_data = $event['post_data'];

if ($topic_attribute != \ernadoo\qte\qte::KEEP)
{
$post_data['topic_attr_id'] = (int) $topic_attribute;
$post_data['topic_attr_user'] = (int) $this->user->data['user_id'];
$post_data['topic_attr_time'] = time();

$this->qte->get_users_by_user_id($this->user->data['user_id']);
}

if ($topic_attribute != \ernadoo\qte\qte::REMOVE)
{
$this->qte->get_users_by_topic_id(array($post_data['topic_id']));
$this->template->assign_var('TOPIC_ATTRIBUTE', $this->qte->attr_display($post_data['topic_attr_id'], $post_data['topic_attr_user'], $post_data['topic_attr_time']));
}
}
}

public function posting_check_attribute($event)
{
$post_data = $event['post_data'];
$post_data['attr_id'] = $this->request->variable('attr_id', \ernadoo\qte\qte::KEEP, false, \phpbb\request\request_interface::POST);

if ($event['post_data']['force_attr'])
{
if ($post_data['attr_id'] == \ernadoo\qte\qte::REMOVE && ($event['mode'] == 'post' || ($event['mode'] == 'edit' && $event['post_data']['topic_first_post_id'] == $event['post_id'])) )
{
$error = $event['error'];
$error[] = $this->user->lang['QTE_ATTRIBUTE_UNSELECTED'];
$event['error'] = $error ;

// init the value
$post_data['attr_id'] = 0;
}
}

$event['post_data'] = $post_data;
}

public function posting_submit_data($event)
{
$topic_attribute = $event['post_data']['attr_id'];

if ($event['mode'] != 'post' && $topic_attribute == $event['post_data']['topic_attr_id'])
{
$topic_attribute = \ernadoo\qte\qte::KEEP;
}
else if (empty($event['post_data']['topic_attr_id']) && $topic_attribute == \ernadoo\qte\qte::REMOVE)
{
$topic_attribute = \ernadoo\qte\qte::KEEP;
}

$data = $event['data'];
$data['attr_id'] = (int) (($event['mode'] == 'post') && !empty($event['post_data']['default_attr'])) ? $event['post_data']['default_attr'] : $topic_attribute;
$event['data'] = $data;
}

public function posting_save_attribute($event)
{
if (isset($event['data']['attr_id']) && $event['data']['attr_id'] != \ernadoo\qte\qte::KEEP)
{
$sql_data = $event['sql_data'];
if ($event['data']['attr_id'] == \ernadoo\qte\qte::REMOVE)
{
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_attr_id = 0';
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_attr_user = 0';
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_attr_time = 0';
}
else
{
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_attr_id = ' . (int) $event['data']['attr_id'];
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_attr_user = ' . (int) $this->user->data['user_id'];
$sql_data[TOPICS_TABLE]['stat'][] = 'topic_attr_time = ' . time();
}
$event['sql_data'] = $sql_data;

if (in_array($event['post_mode'], array('edit_topic', 'edit_first_post')))
{
$attr_name = ($event['data']['attr_id'] != \ernadoo\qte\qte::REMOVE) ? $this->qte->get_attr_name_by_id($event['data']['attr_id']) : '';
$log_data = array(
'forum_id' => $event['data']['forum_id'],
'topic_id' => $event['data']['topic_id'],
$attr_name,
);

$this->log->add('mod', $this->user->data['user_id'], $this->user->ip, 'MCP_ATTRIBUTE_' . ($event['data']['attr_id'] == \ernadoo\qte\qte::REMOVE ? 'REMOVED' : 'UPDATED'), time(), $log_data);
}
}
}
}
119 changes: 119 additions & 0 deletions www/forum/styles/prosilver/template/overall_footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<!-- EVENT overall_footer_content_after -->
<center>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Footer -->
<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-1976924447074293"
data-ad-slot="1886153567"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>

</div>

<!-- EVENT overall_footer_page_body_after -->

<div id="page-footer" class="page-footer" role="contentinfo">
<!-- INCLUDE navbar_footer.html -->

<div class="copyright">
<!-- EVENT overall_footer_copyright_prepend -->
{CREDIT_LINE}
<!-- IF TRANSLATION_INFO --><br />{TRANSLATION_INFO}<!-- ENDIF -->
<!-- EVENT overall_footer_copyright_append -->
<!-- IF DEBUG_OUTPUT --><br />{DEBUG_OUTPUT}<!-- ENDIF -->
<!-- IF U_ACP --><br /><strong><a href="{U_ACP}">{L_ACP}</a></strong><!-- ENDIF -->
</div>

<div id="darkenwrapper" class="darkenwrapper" data-ajax-error-title="{L_AJAX_ERROR_TITLE}" data-ajax-error-text="{L_AJAX_ERROR_TEXT}" data-ajax-error-text-abort="{L_AJAX_ERROR_TEXT_ABORT}" data-ajax-error-text-timeout="{L_AJAX_ERROR_TEXT_TIMEOUT}" data-ajax-error-text-parsererror="{L_AJAX_ERROR_TEXT_PARSERERROR}">
<div id="darken" class="darken">&nbsp;</div>
</div>

<div id="phpbb_alert" class="phpbb_alert" data-l-err="{L_ERROR}" data-l-timeout-processing-req="{L_TIMEOUT_PROCESSING_REQ}">
<a href="#" class="alert_close">
<i class="icon fa-times-circle fa-fw" aria-hidden="true"></i>
</a>
<h3 class="alert_title">&nbsp;</h3><p class="alert_text"></p>
</div>
<div id="phpbb_confirm" class="phpbb_alert">
<a href="#" class="alert_close">
<i class="icon fa-times-circle fa-fw" aria-hidden="true"></i>
</a>
<div class="alert_text"></div>
</div>
</div>

</div>

<div>
<a id="bottom" class="anchor" accesskey="z"></a>
<!-- IF not S_IS_BOT -->{RUN_CRON_TASK}<!-- ENDIF -->
</div>

<script type="text/javascript" src="{T_JQUERY_LINK}"></script>
<!-- IF S_ALLOW_CDN --><script type="text/javascript">window.jQuery || document.write('\x3Cscript src="{T_ASSETS_PATH}/javascript/jquery.min.js?assets_version={T_ASSETS_VERSION}">\x3C/script>');</script><!-- ENDIF -->
<script type="text/javascript" src="{T_ASSETS_PATH}/javascript/core.js?assets_version={T_ASSETS_VERSION}"></script>
<!-- INCLUDEJS forum_fn.js -->
<!-- INCLUDEJS ajax.js -->
<!-- IF S_ALLOW_CDN -->
<script type="text/javascript">
(function($){
var $fa_cdn = $('head').find('link[rel="stylesheet"]').first(),
$span = $('<span class="fa" style="display:none"></span>').appendTo('body');
if ($span.css('fontFamily') !== 'FontAwesome' ) {
$fa_cdn.after('<link href="{T_ASSETS_PATH}/css/font-awesome.min.css" rel="stylesheet">');
$fa_cdn.remove();
}
$span.remove();
})(jQuery);
</script>
<!-- ENDIF -->

<!-- IF S_COOKIE_NOTICE -->
<script src="{T_ASSETS_PATH}/cookieconsent/cookieconsent.min.js?assets_version={T_ASSETS_VERSION}"></script>
<script>
window.addEventListener("load", function(){
window.cookieconsent.initialise({
"palette": {
"popup": {
"background": "#0F538A"
},
"button": {
"background": "#E5E5E5"
}
},
"theme": "classic",
"content": {
"message": "{LA_COOKIE_CONSENT_MSG}",
"dismiss": "{LA_COOKIE_CONSENT_OK}",
"link": "{LA_COOKIE_CONSENT_INFO}",
"href": "{LA_COOKIE_CONSENT_HREF}"
}
})});
</script>
<!-- ENDIF -->

<!-- EVENT overall_footer_after -->

<!-- IF S_PLUPLOAD --><!-- INCLUDE plupload.html --><!-- ENDIF -->
{$SCRIPTS}

<!-- EVENT overall_footer_body_after -->
<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-43478022-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

</body>
</html>

0 comments on commit fc15e3e

Please sign in to comment.