Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!--
- /**
- * Allows users to to rate posts
- *
- * @copyright Copyright (C) 2009 crurf.info
- * @license http://creativecommons.org/licenses/by-sa/3.0/ Creative Commons License version 3.0 or higher
- * @package ajax_rating
- */
- -->
- <extension engine="1.0">
- <id>ajax_rating</id>
- <title>Ajax Rating</title>
- <version>0.0.3</version>
- <description>Adds rating feature for posts.</description>
- <author>Radoslav Salov</author>
- <minversion>1.4</minversion>
- <maxtestedon>1.4.1</maxtestedon>
- <install><![CDATA[
- $update = 0;
- $version = 0;
- $query = array(
- 'SELECT' => 'version',
- 'FROM' => 'extensions',
- 'WHERE' => 'id = \'ajax_rating\'',
- );
- $result = $forum_db->query_build($query);
- if ((int)$forum_db->num_rows($result)) {
- $update ++;
- list($version) = $forum_db->fetch_row($result);
- }
- $query = array(
- 'SELECT' => 'count(*) AS cnt',
- 'FROM' => 'postrating',
- );
- $result = $forum_db->query_build($query);
- if ((int)$forum_db->num_rows($result)) $update ++;
- if ($update == 2) {
- if ($version == '0.0.1') {
- $forum_db->query('ALTER TABLE ' . $forum_db->prefix . 'postrating_det ADD COLUMN rating INT(1) NOT NULL DEFAULT 0');
- $forum_db->query('ALTER TABLE ' . $forum_db->prefix . 'postrating_det DROP INDEX postrating_det_postrating_det_postid_ip');
- $forum_db->query('ALTER TABLE ' . $forum_db->prefix . 'postrating_det DROP INDEX postrating_det_postid_ip');
- }
- } else {
- $schema = array(
- 'FIELDS' => array(
- 'postid' => array(
- 'datatype' => 'SERIAL',
- 'allow_null' => false
- ),
- 'yescnt' => array(
- 'datatype' => 'INT(10)',
- 'allow_null' => false,
- 'default' => 0
- ),
- 'nocnt' => array(
- 'datatype' => 'INT(10)',
- 'allow_null' => false,
- 'default' => 0
- ),
- 'rating' => array(
- 'datatype' => 'FLOAT',
- 'allow_null' => false,
- 'default' => 0
- ),
- 'cnt' => array(
- 'datatype' => 'INT(10)',
- 'allow_null' => false,
- 'default' => 0
- )
- ),
- 'PRIMARY KEY' => array('postid'),
- 'ENGINE' => 'MyISAM'
- );
- $forum_db->create_table('postrating', $schema);
- $schema = array(
- 'FIELDS' => array(
- 'id' => array(
- 'datatype' => 'SERIAL',
- 'allow_null' => false
- ),
- 'postid' => array(
- 'datatype' => 'INT(10)',
- 'allow_null' => false
- ),
- 'ip' => array(
- 'datatype' => 'VARCHAR(15)',
- 'allow_null' => false
- ),
- 'rating' => array(
- 'datatype' => 'INT(1)',
- 'allow_null' => false,
- 'default' => 0
- ),
- 'tstamp' => array(
- 'datatype' => 'INT(11)',
- 'allow_null' => false
- )
- ),
- 'PRIMARY KEY' => array('id'),
- 'ENGINE' => 'MyISAM'
- );
- $forum_db->create_table('postrating_det', $schema);
- }
- $query_conf = array(
- 'INSERT' => 'conf_name, conf_value',
- 'INTO' => 'config',
- 'VALUES' => '"p_ajax_rating_type","0"'
- );
- $forum_db->query_build($query_conf);
- $query_conf = array(
- 'INSERT' => 'conf_name, conf_value',
- 'INTO' => 'config',
- 'VALUES' => '"p_ajax_rating_allow_multiple","0"'
- );
- $forum_db->query_build($query_conf);
- $query_conf = array(
- 'INSERT' => 'conf_name, conf_value',
- 'INTO' => 'config',
- 'VALUES' => '"p_ajax_rating_allow_guest","0"'
- );
- $forum_db->query_build($query_conf);
- $toprated = FORUM_ROOT . 'toprated.php';
- if (!is_file($toprated)) {
- $tr_contents = '<?php
- /**
- * Allows users to to rate posts
- *
- * @copyright Copyright (C) 2009 crurf.info
- * @license http://creativecommons.org/licenses/by-sa/3.0/ Creative Commons License version 3.0 or higher
- * @package ajax_rating
- */
- define(\'FORUM_SKIP_CSRF_CONFIRM\', 1);
- if (!defined(\'FORUM_ROOT\'))
- define(\'FORUM_ROOT\', \'./\');
- require FORUM_ROOT.\'include/common.php\';
- include_once FORUM_ROOT . \'/extensions/ajax_rating/fns.php\';
- if (!$lang_ajax_rating) {
- if (file_exists(FORUM_ROOT . \'/extensions/' . $ext_info['id'] . '/lang/\' . $forum_user[\'language\'] . \'/' . $ext_info['id'] . '2.php\'))
- include_once FORUM_ROOT . \'/extensions/' . $ext_info['id'] . '/lang/\' . $forum_user[\'language\'] . \'/' . $ext_info['id'] . '2.php\';
- else
- include_once FORUM_ROOT . \'/extensions/' . $ext_info['id'] . '/lang/English/' . $ext_info['id'] . '2.php\';
- }
- // Load the viewtopic.php language file
- require FORUM_ROOT.\'lang/\'.$forum_user[\'language\'].\'/topic.php\';
- $type = isset($_GET[\'type\']) ? intval($_GET[\'type\']) : 0;
- $tab = isset($_GET[\'tab\']) ? intval($_GET[\'tab\']) : 0;
- if (!in_array($type, array(0,1))) $type = 0;
- if (!in_array($tab, array(0,1,2))) $tab = 0;
- $curtime = mktime();
- $period = 24 * 60 * 60;
- switch ($tab) {
- case 1:
- $period = 7 * 24 * 60 * 60;
- break;
- case 2:
- $period = 30 * 24 * 60 * 60;
- break;
- }
- $forum_page[\'item_count\'] = 0; // Keep track of post numbers
- // Retrieve the posts (and their respective poster/online status)
- $query = array(
- \'SELECT\' => \'a.rate, t.subject as topicsubj, p.topic_id, u.email, u.title, u.url, u.location, u.signature, u.email_setting, u.num_posts, u.registered, u.admin_note, u.avatar, u.avatar_width, u.avatar_height, p.id, p.poster AS username, p.poster_id, p.poster_ip, p.poster_email, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by, g.g_id, g.g_user_title, o.user_id AS is_online\',
- \'FROM\' => \'(
- SELECT ((sum(pd.rating) * 100) / count(*)) as rate, pd.postid
- FROM \' . $forum_db->prefix . \'postrating_det AS pd
- WHERE pd.tstamp <= \' . $curtime . \' AND pd.tstamp >= \' . ($curtime - $period) . \'
- GROUP BY pd.postid
- ) AS a\',
- \'JOINS\' => array(
- array(
- \'INNER JOIN\' => $forum_db->prefix . \'posts AS p\',
- \'ON\' => \'p.id=a.postid\'
- ),
- array(
- \'INNER JOIN\' => $forum_db->prefix . \'topics AS t\',
- \'ON\' => \'p.topic_id=t.id\'
- ),
- array(
- \'INNER JOIN\' => $forum_db->prefix . \'users AS u\',
- \'ON\' => \'u.id=p.poster_id\'
- ),
- array(
- \'INNER JOIN\' => $forum_db->prefix . \'groups AS g\',
- \'ON\' => \'g.g_id=u.group_id\'
- ),
- array(
- \'LEFT JOIN\' => $forum_db->prefix . \'online AS o\',
- \'ON\' => \'(o.user_id=u.id AND o.user_id!=1 AND o.idle=0)\'
- ),
- ),
- \'ORDER BY\' => \'a.rate \' . ($type == 1 ? \'ASC\' : \'DESC\'),
- \'LIMIT\' => 5,
- \'PARAMS\' => array(\'NO_PREFIX\' => 1)
- );
- $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
- if (!$forum_db->num_rows($result)) {
- message($lang_common[\'Bad request\']);
- } else {
- define(\'FORUM_PAGE\', \'toprated\');
- require FORUM_ROOT.\'header.php\';
- // START SUBST - <!-- forum_main -->
- ob_start();
- ?>
- <div class="admin-menu gen-content">
- <ul>
- <li class="<?php echo ($type == 0 ? \'active \' : \'\'); ?>first-item"><a href="?type=0&tab=<? echo $tab; ?>"><span><?php echo $lang_ajax_rating[\'Best\']; ?></span></a></li>
- <li class="<?php echo ($type == 1 ? \'active \' : \'\'); ?>normal"><a href="?type=1&tab=<? echo $tab; ?>"><span><?php echo $lang_ajax_rating[\'Worst\']; ?></span></a></li>
- </ul>
- </div>
- <div class="admin-submenu gen-content">
- <ul>
- <li class="<?php echo ($tab == 0 ? \'active \' : \'\'); ?>first-item"><a href="?type=<? echo $type; ?>&tab=0"><span><?php echo $lang_ajax_rating[\'Last day\']; ?></span></a></li>
- <li class="<?php echo ($tab == 1 ? \'active \' : \'\'); ?>normal"><a href="?type=<? echo $type; ?>&tab=1"><span><?php echo $lang_ajax_rating[\'Last week\']; ?></span></a></li>
- <li class="<?php echo ($tab == 2 ? \'active \' : \'\'); ?>normal"><a href="?type=<? echo $type; ?>&tab=2"><span><?php echo $lang_ajax_rating[\'Last month\']; ?></span></a></li>
- </ul>
- </div>
- <div class="main-content main-topic" id="forum1">
- <?php
- while ($cur_post = $forum_db->fetch_assoc($result)) {
- ++$forum_page[\'item_count\'];
- $forum_page[\'post_ident\'] = array();
- $forum_page[\'author_ident\'] = array();
- $forum_page[\'author_info\'] = array();
- $forum_page[\'post_options\'] = array();
- $forum_page[\'post_contacts\'] = array();
- $forum_page[\'post_actions\'] = array();
- $forum_page[\'message\'] = array();
- // Generate the post heading
- $forum_page[\'post_ident\'][\'num\'] = \'<span class="post-num">\'.forum_number_format($forum_page[\'start_from\'] + $forum_page[\'item_count\']).\'</span>\';
- if ($cur_post[\'poster_id\'] > 1)
- $forum_page[\'post_ident\'][\'byline\'] = \'<span class="post-byline">\'.sprintf((($cur_post[\'id\'] == $cur_topic[\'first_post_id\']) ? $lang_topic[\'Topic byline\'] : $lang_topic[\'Reply byline\']), (($forum_user[\'g_view_users\'] == \'1\') ? \'<a title="\'.sprintf($lang_topic[\'Go to profile\'], forum_htmlencode($cur_post[\'username\'])).\'" href="\'.forum_link($forum_url[\'user\'], $cur_post[\'poster_id\']).\'">\'.forum_htmlencode($cur_post[\'username\']).\'</a>\' : \'<strong>\'.forum_htmlencode($cur_post[\'username\']).\'</strong>\')).\'</span>\';
- else
- $forum_page[\'post_ident\'][\'byline\'] = \'<span class="post-byline">\'.sprintf((($cur_post[\'id\'] == $cur_topic[\'first_post_id\']) ? $lang_topic[\'Topic byline\'] : $lang_topic[\'Reply byline\']), \'<strong>\'.forum_htmlencode($cur_post[\'username\']).\'</strong>\').\'</span>\';
- $forum_page[\'post_ident\'][\'link\'] = \'<span class="post-link"><a class="permalink" href="\'.forum_link($forum_url[\'topic\'], $cur_post[\'topic_id\']).\'"><b>\'. $cur_post[\'topicsubj\'] .\'</b></a> - <a class="permalink" rel="bookmark" title="\'.$lang_topic[\'Permalink post\'].\'" href="\'.forum_link($forum_url[\'post\'], $cur_post[\'id\']).\'">\'.format_time($cur_post[\'posted\']).\'</a></span>\';
- ($hook = get_hook(\'vt_row_pre_post_ident_merge\')) ? eval($hook) : null;
- if (isset($user_data_cache[$cur_post[\'poster_id\']][\'author_ident\']))
- $forum_page[\'author_ident\'] = $user_data_cache[$cur_post[\'poster_id\']][\'author_ident\'];
- else
- {
- // Generate author identification
- if ($cur_post[\'poster_id\'] > 1)
- {
- if ($forum_config[\'o_avatars\'] == \'1\' && $forum_user[\'show_avatars\'] != \'0\')
- {
- $forum_page[\'avatar_markup\'] = generate_avatar_markup($cur_post[\'poster_id\'], $cur_post[\'avatar\'], $cur_post[\'avatar_width\'], $cur_post[\'avatar_height\'], $cur_post[\'poster\']);
- if (!empty($forum_page[\'avatar_markup\']))
- $forum_page[\'author_ident\'][\'avatar\'] = \'<li class="useravatar">\'.$forum_page[\'avatar_markup\'].\'</li>\';
- }
- $forum_page[\'author_ident\'][\'username\'] = \'<li class="username">\'.(($forum_user[\'g_view_users\'] == \'1\') ? \'<a title="\'.sprintf($lang_topic[\'Go to profile\'], forum_htmlencode($cur_post[\'username\'])).\'" href="\'.forum_link($forum_url[\'user\'], $cur_post[\'poster_id\']).\'">\'.forum_htmlencode($cur_post[\'username\']).\'</a>\' : \'<strong>\'.forum_htmlencode($cur_post[\'username\']).\'</strong>\').\'</li>\';
- $forum_page[\'author_ident\'][\'usertitle\'] = \'<li class="usertitle"><span>\'.get_title($cur_post).\'</span></li>\';
- if ($cur_post[\'is_online\'] == $cur_post[\'poster_id\'])
- $forum_page[\'author_ident\'][\'status\'] = \'<li class="userstatus"><span>\'.$lang_topic[\'Online\'].\'</span></li>\';
- else
- $forum_page[\'author_ident\'][\'status\'] = \'<li class="userstatus"><span>\'.$lang_topic[\'Offline\'].\'</span></li>\';
- }
- else
- {
- $forum_page[\'author_ident\'][\'username\'] = \'<li class="username"><strong>\'.forum_htmlencode($cur_post[\'username\']).\'</strong></li>\';
- $forum_page[\'author_ident\'][\'usertitle\'] = \'<li class="usertitle"><span>\'.get_title($cur_post).\'</span></li>\';
- }
- }
- if (isset($user_data_cache[$cur_post[\'poster_id\']][\'author_info\']))
- $forum_page[\'author_info\'] = $user_data_cache[$cur_post[\'poster_id\']][\'author_info\'];
- else
- {
- // Generate author information
- if ($cur_post[\'poster_id\'] > 1)
- {
- if ($forum_config[\'o_show_user_info\'] == \'1\')
- {
- if ($cur_post[\'location\'] != \'\')
- {
- if ($forum_config[\'o_censoring\'] == \'1\')
- $cur_post[\'location\'] = censor_words($cur_post[\'location\']);
- $forum_page[\'author_info\'][\'from\'] = \'<li><span>\'.$lang_topic[\'From\'].\' <strong>\'.forum_htmlencode($cur_post[\'location\']).\'</strong></span></li>\';
- }
- $forum_page[\'author_info\'][\'registered\'] = \'<li><span>\'.$lang_topic[\'Registered\'].\' <strong>\'.format_time($cur_post[\'registered\'], 1).\'</strong></span></li>\';
- if ($forum_config[\'o_show_post_count\'] == \'1\' || $forum_user[\'is_admmod\'])
- $forum_page[\'author_info\'][\'posts\'] = \'<li><span>\'.$lang_topic[\'Posts info\'].\' <strong>\'.forum_number_format($cur_post[\'num_posts\']).\'</strong></span></li>\';
- }
- if ($forum_user[\'is_admmod\'])
- {
- if ($cur_post[\'admin_note\'] != \'\')
- $forum_page[\'author_info\'][\'note\'] = \'<li><span>\'.$lang_topic[\'Note\'].\' <strong>\'.forum_htmlencode($cur_post[\'admin_note\']).\'</strong></span></li>\';
- }
- }
- }
- // Generate IP information for moderators/administrators
- if ($forum_user[\'is_admmod\'])
- $forum_page[\'author_info\'][\'ip\'] = \'<li><span>\'.$lang_topic[\'IP\'].\' <a href="\'.forum_link($forum_url[\'get_host\'], $cur_post[\'id\']).\'">\'.$cur_post[\'poster_ip\'].\'</a></span></li>\';
- // Generate author contact details
- if ($forum_config[\'o_show_user_info\'] == \'1\')
- {
- if (isset($user_data_cache[$cur_post[\'poster_id\']][\'post_contacts\']))
- $forum_page[\'post_contacts\'] = $user_data_cache[$cur_post[\'poster_id\']][\'post_contacts\'];
- else
- {
- if ($cur_post[\'poster_id\'] > 1)
- {
- if ($cur_post[\'url\'] != \'\')
- $forum_page[\'post_contacts\'][\'url\'] = \'<span class="user-url\'.(empty($forum_page[\'post_contacts\']) ? \' first-item\' : \'\').\'"><a class="external" href="\'.forum_htmlencode(($forum_config[\'o_censoring\'] == \'1\') ? censor_words($cur_post[\'url\']) : $cur_post[\'url\']).\'">\'.sprintf($lang_topic[\'Visit website\'], \'<span>\'.sprintf($lang_topic[\'User possessive\'], forum_htmlencode($cur_post[\'username\'])).\'</span>\').\'</a></span>\';
- if ((($cur_post[\'email_setting\'] == \'0\' && !$forum_user[\'is_guest\']) || $forum_user[\'is_admmod\']) && $forum_user[\'g_send_email\'] == \'1\')
- $forum_page[\'post_contacts\'][\'email\'] = \'<span class="user-email\'.(empty($forum_page[\'post_contacts\']) ? \' first-item\' : \'\').\'"><a href="mailto:\'.forum_htmlencode($cur_post[\'email\']).\'">\'.$lang_topic[\'E-mail\'].\'<span> \'.forum_htmlencode($cur_post[\'username\']).\'</span></a></span>\';
- else if ($cur_post[\'email_setting\'] == \'1\' && !$forum_user[\'is_guest\'] && $forum_user[\'g_send_email\'] == \'1\')
- $forum_page[\'post_contacts\'][\'email\'] = \'<span class="user-email\'.(empty($forum_page[\'post_contacts\']) ? \' first-item\' : \'\').\'"><a href="\'.forum_link($forum_url[\'email\'], $cur_post[\'poster_id\']).\'">\'.$lang_topic[\'E-mail\'].\'<span> \'.forum_htmlencode($cur_post[\'username\']).\'</span></a></span>\';
- }
- else
- {
- if ($cur_post[\'poster_email\'] != \'\' && !$forum_user[\'is_guest\'] && $forum_user[\'g_send_email\'] == \'1\')
- $forum_page[\'post_contacts\'][\'email\'] = \'<span class="user-email\'.(empty($forum_page[\'post_contacts\']) ? \' first-item\' : \'\').\'"><a href="mailto:\'.forum_htmlencode($cur_post[\'poster_email\']).\'">\'.$lang_topic[\'E-mail\'].\'<span> \'.forum_htmlencode($cur_post[\'username\']).\'</span></a></span>\';
- }
- }
- ($hook = get_hook(\'vt_row_pre_post_contacts_merge\')) ? eval($hook) : null;
- if (!empty($forum_page[\'post_contacts\']))
- $forum_page[\'post_options\'][\'contacts\'] = \'<p class="post-contacts">\'.implode(\' \', $forum_page[\'post_contacts\']).\'</p>\';
- }
- // Generate the post options links
- if (!$forum_user[\'is_guest\'])
- {
- $forum_page[\'post_actions\'][\'report\'] = \'<span class="report-post\'.(empty($forum_page[\'post_actions\']) ? \' first-item\' : \'\').\'"><a href="\'.forum_link($forum_url[\'report\'], $cur_post[\'id\']).\'">\'.$lang_topic[\'Report\'].\'<span> \'.$lang_topic[\'Post\'].\' \'.forum_number_format($forum_page[\'start_from\'] + $forum_page[\'item_count\']).\'</span></a></span>\';
- if (!$forum_page[\'is_admmod\'])
- {
- if ($cur_topic[\'closed\'] == \'0\')
- {
- if ($cur_post[\'poster_id\'] == $forum_user[\'id\'])
- {
- if (($forum_page[\'start_from\'] + $forum_page[\'item_count\']) == 1 && $forum_user[\'g_delete_topics\'] == \'1\')
- $forum_page[\'post_actions\'][\'delete\'] = \'<span class="delete-topic\'.(empty($forum_page[\'post_actions\']) ? \' first-item\' : \'\').\'"><a href="\'.forum_link($forum_url[\'delete\'], $cur_topic[\'first_post_id\']).\'">\'.$lang_topic[\'Delete topic\'].\'</a></span>\';
- if (($forum_page[\'start_from\'] + $forum_page[\'item_count\']) > 1 && $forum_user[\'g_delete_posts\'] == \'1\')
- $forum_page[\'post_actions\'][\'delete\'] = \'<span class="delete-post\'.(empty($forum_page[\'post_actions\']) ? \' first-item\' : \'\').\'"><a href="\'.forum_link($forum_url[\'delete\'], $cur_post[\'id\']).\'">\'.$lang_topic[\'Delete\'].\'<span> \'.$lang_topic[\'Post\'].\' \'.forum_number_format($forum_page[\'start_from\'] + $forum_page[\'item_count\']).\'</span></a></span>\';
- if ($forum_user[\'g_edit_posts\'] == \'1\')
- $forum_page[\'post_actions\'][\'edit\'] = \'<span class="edit-post\'.(empty($forum_page[\'post_actions\']) ? \' first-item\' : \'\').\'"><a href="\'.forum_link($forum_url[\'edit\'], $cur_post[\'id\']).\'">\'.$lang_topic[\'Edit\'].\'<span> \'.$lang_topic[\'Post\'].\' \'.forum_number_format($forum_page[\'start_from\'] + $forum_page[\'item_count\']).\'</span></a></span>\';
- }
- if (($cur_topic[\'post_replies\'] == \'\' && $forum_user[\'g_post_replies\'] == \'1\') || $cur_topic[\'post_replies\'] == \'1\')
- $forum_page[\'post_actions\'][\'quote\'] = \'<span class="quote-post\'.(empty($forum_page[\'post_actions\']) ? \' first-item\' : \'\').\'"><a href="\'.forum_link($forum_url[\'quote\'], array($id, $cur_post[\'id\'])).\'">\'.$lang_topic[\'Quote\'].\'<span> \'.$lang_topic[\'Post\'].\' \'.forum_number_format($forum_page[\'start_from\'] + $forum_page[\'item_count\']).\'</span></a></span>\';
- }
- }
- else
- {
- if (($forum_page[\'start_from\'] + $forum_page[\'item_count\']) == 1)
- $forum_page[\'post_actions\'][\'delete\'] = \'<span class="delete-topic\'.(empty($forum_page[\'post_actions\']) ? \' first-item\' : \'\').\'"><a href="\'.forum_link($forum_url[\'delete\'], $cur_topic[\'first_post_id\']).\'">\'.$lang_topic[\'Delete topic\'].\'</a></span>\';
- else
- $forum_page[\'post_actions\'][\'delete\'] = \'<span class="delete-post\'.(empty($forum_page[\'post_actions\']) ? \' first-item\' : \'\').\'"><a href="\'.forum_link($forum_url[\'delete\'], $cur_post[\'id\']).\'">\'.$lang_topic[\'Delete\'].\'<span> \'.$lang_topic[\'Post\'].\' \'.forum_number_format($forum_page[\'start_from\'] + $forum_page[\'item_count\']).\'</span></a></span>\';
- $forum_page[\'post_actions\'][\'edit\'] = \'<span class="edit-post\'.(empty($forum_page[\'post_actions\']) ? \' first-item\' : \'\').\'"><a href="\'.forum_link($forum_url[\'edit\'], $cur_post[\'id\']).\'">\'.$lang_topic[\'Edit\'].\'<span> \'.$lang_topic[\'Post\'].\' \'.forum_number_format($forum_page[\'start_from\'] + $forum_page[\'item_count\']).\'</span></a></span>\';
- $forum_page[\'post_actions\'][\'quote\'] = \'<span class="quote-post\'.(empty($forum_page[\'post_actions\']) ? \' first-item\' : \'\').\'"><a href="\'.forum_link($forum_url[\'quote\'], array($id, $cur_post[\'id\'])).\'">\'.$lang_topic[\'Quote\'].\'<span> \'.$lang_topic[\'Post\'].\' \'.forum_number_format($forum_page[\'start_from\'] + $forum_page[\'item_count\']).\'</span></a></span>\';
- }
- }
- else
- {
- if ($cur_topic[\'closed\'] == \'0\')
- {
- if (($cur_topic[\'post_replies\'] == \'\' && $forum_user[\'g_post_replies\'] == \'1\') || $cur_topic[\'post_replies\'] == \'1\')
- $forum_page[\'post_actions\'][\'quote\'] = \'<span class="report-post\'.(empty($forum_page[\'post_actions\']) ? \' first-item\' : \'\').\'"><a href="\'.forum_link($forum_url[\'quote\'], array($id, $cur_post[\'id\'])).\'">\'.$lang_topic[\'Quote\'].\'<span> \'.$lang_topic[\'Post\'].\' \'.forum_number_format($forum_page[\'start_from\'] + $forum_page[\'item_count\']).\'</span></a></span>\';
- }
- }
- ($hook = get_hook(\'vt_row_pre_post_actions_merge\')) ? eval($hook) : null;
- if (!empty($forum_page[\'post_actions\']))
- $forum_page[\'post_options\'][\'actions\'] = \'<p class="post-actions">\'.implode(\' \', $forum_page[\'post_actions\']).\'</p>\';
- // Give the post some class
- $forum_page[\'item_status\'] = array(
- \'post\',
- ($forum_page[\'item_count\'] % 2 != 0) ? \'odd\' : \'even\'
- );
- if ($forum_page[\'item_count\'] == 1)
- $forum_page[\'item_status\'][\'firstpost\'] = \'firstpost\';
- if (($forum_page[\'start_from\'] + $forum_page[\'item_count\']) == $forum_page[\'finish_at\'])
- $forum_page[\'item_status\'][\'lastpost\'] = \'lastpost\';
- if ($cur_post[\'id\'] == $cur_topic[\'first_post_id\'])
- $forum_page[\'item_status\'][\'topicpost\'] = \'topicpost\';
- else
- $forum_page[\'item_status\'][\'replypost\'] = \'replypost\';
- // Generate the post title
- if ($cur_post[\'id\'] == $cur_topic[\'first_post_id\'])
- $forum_page[\'item_subject\'] = sprintf($lang_topic[\'Topic title\'], $cur_topic[\'subject\']);
- else
- $forum_page[\'item_subject\'] = sprintf($lang_topic[\'Reply title\'], $cur_topic[\'subject\']);
- $forum_page[\'item_subject\'] = forum_htmlencode($forum_page[\'item_subject\']);
- // Perform the main parsing of the message (BBCode, smilies, censor words etc)
- $forum_page[\'message\'][\'message\'] = parse_message($cur_post[\'message\'], $cur_post[\'hide_smilies\']);
- if ($cur_post[\'edited\'] != \'\')
- $forum_page[\'message\'][\'edited\'] = \'<p class="lastedit"><em>\'.sprintf($lang_topic[\'Last edited\'], forum_htmlencode($cur_post[\'edited_by\']), format_time($cur_post[\'edited\'])).\'</em></p>\';
- // Do signature parsing/caching
- if ($cur_post[\'signature\'] != \'\' && $forum_user[\'show_sig\'] != \'0\' && $forum_config[\'o_signatures\'] == \'1\')
- {
- if (!isset($signature_cache[$cur_post[\'poster_id\']]))
- $signature_cache[$cur_post[\'poster_id\']] = parse_signature($cur_post[\'signature\']);
- $forum_page[\'message\'][\'signature\'] = \'<div class="sig-content"><span class="sig-line"><!-- --></span>\'.$signature_cache[$cur_post[\'poster_id\']].\'</div>\';
- }
- ?>
- <div class="<?php echo implode(\' \', $forum_page[\'item_status\']) ?>">
- <div id="p<?php echo $cur_post[\'id\'] ?>" class="posthead">
- <h3 class="hn post-ident"><?php echo implode(\' \', $forum_page[\'post_ident\']) ?></h3>
- </div>
- <div class="postbody<?php echo ($cur_post[\'is_online\'] == $cur_post[\'poster_id\']) ? \' online\' : \'\' ?>">
- <div class="post-author">
- <ul class="author-ident">
- <?php echo implode("\n\t\t\t\t\t\t", $forum_page[\'author_ident\'])."\n" ?>
- </ul>
- <ul class="author-info">
- <?php echo implode("\n\t\t\t\t\t\t", $forum_page[\'author_info\'])."\n" ?>
- </ul>
- </div>
- <div class="post-entry">
- <h4 id="pc<?php echo $cur_post[\'id\'] ?>" class="entry-title hn"><?php echo $forum_page[\'item_subject\'] ?></h4>
- <div class="entry-content">
- <?php echo implode("\n\t\t\t\t\t\t", $forum_page[\'message\'])."\n" ?>
- </div>
- </div>
- </div>
- <div class="postfoot">
- <div class="post-options">
- <?php
- AR_getRating($cur_post[\'id\'], $forum_page[\'post_options\'], $forum_user[\'is_guest\']);
- echo implode("\n\t\t\t\t\t", $forum_page[\'post_options\'])."\n";
- ?>
- </div>
- </div>
- </div>
- <?php
- }
- ?>
- </div>
- <?php
- $tpl_temp = forum_trim(ob_get_contents());
- $tpl_main = str_replace(\'<!-- forum_main -->\', $tpl_temp, $tpl_main);
- ob_end_clean();
- // END SUBST - <!-- forum_main -->
- require FORUM_ROOT.\'footer.php\';
- }
- ?>
- ';
- $fp = fopen($toprated, 'w');
- fwrite($fp, $tr_contents);
- fclose($fp);
- }
- ]]></install>
- <uninstall><![CDATA[
- $forum_db->drop_table('postrating');
- $forum_db->drop_table('postrating_det');
- $query_conf = array(
- 'DELETE' => 'config',
- 'WHERE' => 'conf_name="p_ajax_rating_type"'
- );
- $forum_db->query_build($query_conf);
- $query_conf = array(
- 'DELETE' => 'config',
- 'WHERE' => 'conf_name="p_ajax_rating_allow_multiple"'
- );
- $forum_db->query_build($query_conf);
- $query_conf = array(
- 'DELETE' => 'config',
- 'WHERE' => 'conf_name="p_ajax_rating_allow_guest"'
- );
- $forum_db->query_build($query_conf);
- $toprated = FORUM_ROOT . 'toprated.php';
- if (is_file($toprated)) {
- unlink($toprated);
- }
- ]]></uninstall>
- <hooks>
- <hook id="hd_head"><![CDATA[
- if (FORUM_PAGE == 'viewtopic' || FORUM_PAGE == 'toprated') {
- require_once FORUM_ROOT.'include/parser.php';
- $forum_head['style_ajax_rating'] = '<link rel="stylesheet" type="text/css" media="screen" href="'.$ext_info['url'].'/ajax_rating.css" />';
- $forum_head['prototypejs'] = '<script type="text/javascript" src="'.$ext_info['url'].'/js/prototype.js"></script>';
- $forum_head['js_ajax_rating'] = '<script type="text/javascript" src="'.$ext_info['url'].'/js/ajax_rating.js?baseUri='.$base_url.'/&extUri='.$ext_info['url'].'"></script>';
- }
- ]]></hook>
- <hook id="vt_start, mi_start"><![CDATA[
- include_once $ext_info['path'].'/fns.php';
- ]]></hook>
- <hook id="vt_row_pre_display"><![CDATA[
- AR_getRating($cur_post['id'], $forum_page['post_options'], $forum_user['is_guest']);
- ]]></hook>
- <hook id="mi_new_action"><![CDATA[
- AR_processRequest($action);
- ]]></hook>
- <hook id="co_modify_url_scheme"><![CDATA[
- // disable token validation for chat submit
- if(preg_match('/(.*)\/misc.php\?action\=ajax_rating$/', get_current_url(), $m)) {
- if (is_array($m)) {
- $_POST['csrf_token'] = generate_form_token($m[1].'/misc.php?action=ajax_rating');
- } else {
- $_POST['csrf_token'] = generate_form_token($base_url.'/misc.php?action=ajax_rating');
- }
- }
- ]]></hook>
- <hook id="aop_features_pre_header_load"><![CDATA[
- if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php'))
- include_once $ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php';
- else
- include_once $ext_info['path'].'/lang/English/'.$ext_info['id'].'.php';
- ]]></hook>
- <hook id="aop_features_validation"><![CDATA[
- if (!isset($form['ajax_rating_type']) || $form['ajax_rating_type'] != '1') $form['ajax_rating_type'] = '0';
- if (!isset($form['ajax_rating_allow_guest']) || $form['ajax_rating_allow_guest'] != '1') $form['ajax_rating_allow_guest'] = '0';
- if (!isset($form['ajax_rating_allow_multiple']) || $form['ajax_rating_allow_multiple'] != '1') $form['ajax_rating_allow_multiple'] = '0';
- ]]></hook>
- <hook id="aop_features_avatars_fieldset_end"><![CDATA[
- ?>
- <div class="content-head">
- <h2 class="hn"><span><?php echo $lang_ajax_rating['Settings header'] ?></span></h2>
- </div>
- <fieldset class="frm-group group1">
- <?php
- if (defined('AR_DEBUG_MODE')) {
- ?>
- <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
- <div class="sf-box checkbox">
- <span class="fld-input">
- <input id="fld<?php echo ++$forum_page['fld_count'] ?>" type="checkbox" name="form[ajax_rating_type]" value="1"<?php if ($forum_config['p_ajax_rating_type'] == '1') echo ' checked="checked"' ?>/>
- </span>
- <label for="fld<?php echo ++$forum_page['fld_count'] ?>">
- <span><?php echo $lang_ajax_rating['Rating type'] ?></span>
- </label>
- </div>
- </div>
- <?php
- }
- ?>
- <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
- <div class="sf-box checkbox">
- <span class="fld-input">
- <input id="fld<?php echo ++$forum_page['fld_count'] ?>" type="checkbox" name="form[ajax_rating_allow_multiple]" value="1"<?php if ($forum_config['p_ajax_rating_allow_multiple'] == '1') echo ' checked="checked"' ?>/>
- </span>
- <label for="fld<?php echo ++$forum_page['fld_count'] ?>">
- <span><?php echo $lang_ajax_rating['Multiple rates'] ?></span>
- </label>
- </div>
- </div>
- <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
- <div class="sf-box checkbox">
- <span class="fld-input">
- <input id="fld<?php echo ++$forum_page['fld_count'] ?>" type="checkbox" name="form[ajax_rating_allow_guest]" value="1"<?php if ($forum_config['p_ajax_rating_allow_guest'] == '1') echo ' checked="checked"' ?>/>
- </span>
- <label for="fld<?php echo ++$forum_page['fld_count'] ?>">
- <span><?php echo $lang_ajax_rating['Allow guest'] ?></span>
- </label>
- </div>
- </div>
- </fieldset>
- <?php
- ]]></hook>
- <hook id="fn_generate_navlinks_end"><![CDATA[
- if (!$lang_ajax_rating) {
- if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php'))
- include_once $ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php';
- else
- include_once $ext_info['path'].'/lang/English/'.$ext_info['id'].'.php';
- }
- $links['ajax_rating_toprated'] = '<li id="navtoprated"'.((FORUM_PAGE == 'toprated') ? ' class="isactive"' : '').'><a href="'.forum_link('toprated.php').'">'.$lang_ajax_rating['Post ratings'].'</a></li>';
- ]]></hook>
- </hooks>
- </extension>
Add Comment
Please, Sign In to add comment