Guest User

Ajax Rating manifest.xml

a guest
Dec 28th, 2011
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 29.77 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE extension SYSTEM "ext-1.0.dtd">
  3.  
  4. <!--
  5. /**
  6. * Allows users to to rate posts
  7. *
  8. * @copyright Copyright (C) 2009 crurf.info
  9. * @license http://creativecommons.org/licenses/by-sa/3.0/ Creative Commons License version 3.0 or higher
  10. * @package ajax_rating
  11. */
  12. -->
  13.  
  14. <extension engine="1.0">
  15.     <id>ajax_rating</id>
  16.     <title>Ajax Rating</title>
  17.     <version>0.0.2</version>
  18.     <description>Adds rating feature for posts.</description>
  19.     <author>xxx</author>
  20.     <minversion>1.3.2</minversion>
  21.     <maxtestedon>1.3.4</maxtestedon>
  22.  
  23.     <install><![CDATA[
  24.        
  25.         $update = 0;
  26.         $version = 0;
  27.        
  28.         $query = array(
  29.           'SELECT' => 'version',
  30.           'FROM' => 'extensions',
  31.           'WHERE' => 'id = \'ajax_rating\'',
  32.         );
  33.        
  34.         $result = $forum_db->query_build($query);
  35.         if ((int)$forum_db->num_rows($result)) {
  36.             $update ++;
  37.             list($version) = $forum_db->fetch_row($result);
  38.         }
  39.        
  40.         $query = array(
  41.           'SELECT' => 'count(*) AS cnt',
  42.           'FROM' => 'postrating',
  43.         );
  44.        
  45.         $result = $forum_db->query_build($query);
  46.         if ((int)$forum_db->num_rows($result)) $update ++;
  47.        
  48.         if ($update == 2) {
  49.             if ($version == '0.0.1') {
  50.                 $forum_db->query('ALTER TABLE ' . $forum_db->prefix . 'postrating_det ADD COLUMN rating INT(1) NOT NULL DEFAULT 0');
  51.                 $forum_db->query('ALTER TABLE ' . $forum_db->prefix . 'postrating_det DROP INDEX postrating_det_postrating_det_postid_ip');
  52.                 $forum_db->query('ALTER TABLE ' . $forum_db->prefix . 'postrating_det DROP INDEX postrating_det_postid_ip');
  53.             }
  54.         } else {
  55.             $schema = array(
  56.                 'FIELDS' => array(
  57.                     'postid'        => array(
  58.                         'datatype'      => 'SERIAL',
  59.                         'allow_null'    => false
  60.                     ),
  61.                     'yescnt'    => array(
  62.                         'datatype'      => 'INT(10)',
  63.                         'allow_null'    => false,
  64.                         'default'       => 0
  65.                     ),
  66.                     'nocnt' => array(
  67.                         'datatype'      => 'INT(10)',
  68.                         'allow_null'    => false,
  69.                         'default'       => 0
  70.                     ),
  71.                     'rating'    => array(
  72.                         'datatype'      => 'FLOAT',
  73.                         'allow_null'    => false,
  74.                         'default'       => 0
  75.                     ),
  76.                     'cnt'   => array(
  77.                         'datatype'      => 'INT(10)',
  78.                         'allow_null'    => false,
  79.                         'default'       => 0
  80.                     )
  81.                 ),
  82.                 'PRIMARY KEY'   =>  array('postid'),
  83.                 'ENGINE'        =>  'MyISAM'
  84.             );
  85.             $forum_db->create_table('postrating', $schema);
  86.  
  87.             $schema = array(
  88.                 'FIELDS'        => array(
  89.                     'id'            => array(
  90.                         'datatype'      => 'SERIAL',
  91.                         'allow_null'    => false
  92.                     ),
  93.                     'postid'        => array(
  94.                         'datatype'      => 'INT(10)',
  95.                         'allow_null'    => false
  96.                     ),
  97.                     'ip'        => array(
  98.                         'datatype'      => 'VARCHAR(15)',
  99.                         'allow_null'    => false
  100.                     ),
  101.                     'rating'    => array(
  102.                         'datatype'      => 'INT(1)',
  103.                         'allow_null'    => false,
  104.                         'default'       => 0
  105.                     ),
  106.                     'tstamp'            => array(
  107.                         'datatype'      => 'INT(11)',
  108.                         'allow_null'    => false
  109.                     )
  110.                 ),
  111.                 'PRIMARY KEY'   =>  array('id'),
  112.                 'ENGINE'        =>  'MyISAM'
  113.             );
  114.             $forum_db->create_table('postrating_det', $schema);
  115.         }
  116.        
  117.         $query_conf = array(
  118.             'INSERT'    => 'conf_name, conf_value',
  119.             'INTO'      => 'config',
  120.             'VALUES'    => '"p_ajax_rating_type","0"'
  121.         );
  122.         $forum_db->query_build($query_conf);
  123.        
  124.         $query_conf = array(
  125.             'INSERT'    => 'conf_name, conf_value',
  126.             'INTO'      => 'config',
  127.             'VALUES'    => '"p_ajax_rating_allow_multiple","0"'
  128.         );
  129.         $forum_db->query_build($query_conf);
  130.        
  131.         $query_conf = array(
  132.             'INSERT'    => 'conf_name, conf_value',
  133.             'INTO'      => 'config',
  134.             'VALUES'    => '"p_ajax_rating_allow_guest","0"'
  135.         );
  136.         $forum_db->query_build($query_conf);
  137.         $toprated = FORUM_ROOT . 'toprated.php';
  138.         if (!is_file($toprated)) {
  139.             $tr_contents = '<?php
  140. /**
  141. * Allows users to to rate posts
  142. *
  143. * @copyright Copyright (C) 2009 crurf.info
  144. * @license http://creativecommons.org/licenses/by-sa/3.0/ Creative Commons License version 3.0 or higher
  145. * @package ajax_rating
  146. */
  147.  
  148. define(\'FORUM_SKIP_CSRF_CONFIRM\', 1);
  149.  
  150. if (!defined(\'FORUM_ROOT\'))
  151.     define(\'FORUM_ROOT\', \'./\');
  152. require FORUM_ROOT.\'include/common.php\';
  153.  
  154. include_once FORUM_ROOT . \'/extensions/ajax_rating/fns.php\';
  155.  
  156. if (!$lang_ajax_rating) {
  157.     if (file_exists(FORUM_ROOT . \'/extensions/' . $ext_info['id'] . '/lang/\' . $forum_user[\'language\'] . \'/' . $ext_info['id'] . '2.php\'))
  158.         include_once FORUM_ROOT . \'/extensions/' . $ext_info['id'] . '/lang/\' . $forum_user[\'language\'] . \'/' . $ext_info['id'] . '2.php\';
  159.     else
  160.         include_once FORUM_ROOT . \'/extensions/' . $ext_info['id'] . '/lang/English/' . $ext_info['id'] . '2.php\';
  161. }
  162.  
  163. // Load the viewtopic.php language file
  164. require FORUM_ROOT.\'lang/\'.$forum_user[\'language\'].\'/topic.php\';
  165.  
  166. $type = isset($_GET[\'type\']) ? intval($_GET[\'type\']) : 0;
  167. $tab = isset($_GET[\'tab\']) ? intval($_GET[\'tab\']) : 0;
  168.  
  169. if (!in_array($type, array(0,1))) $type = 0;
  170. if (!in_array($tab, array(0,1,2))) $tab = 0;
  171.  
  172. $curtime = mktime();
  173. $period = 24 * 60 * 60;
  174. switch ($tab) {
  175.     case 1:
  176.         $period = 7 * 24 * 60 * 60;
  177.         break;
  178.     case 2:
  179.         $period = 30 * 24 * 60 * 60;
  180.         break;
  181. }
  182.  
  183. $forum_page[\'item_count\'] = 0;    // Keep track of post numbers
  184.  
  185. // Retrieve the posts (and their respective poster/online status)
  186. $query = array(
  187.     \'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, 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\',
  188.     \'FROM\' => \'(
  189.         SELECT ((sum(pd.rating) * 100) / count(*)) as rate, pd.postid
  190.         FROM \' . $forum_db->prefix . \'postrating_det AS pd
  191.         WHERE pd.tstamp <= \' . $curtime . \' AND pd.tstamp >= \' . ($curtime - $period) . \'
  192.         GROUP BY pd.postid
  193.     ) AS a\',
  194.     \'JOINS\'       => array(
  195.         array(
  196.             \'INNER JOIN\'  => $forum_db->prefix . \'posts AS p\',
  197.             \'ON\'          => \'p.id=a.postid\'
  198.         ),
  199.         array(
  200.             \'INNER JOIN\'  => $forum_db->prefix . \'topics AS t\',
  201.             \'ON\'          => \'p.topic_id=t.id\'
  202.         ),
  203.         array(
  204.             \'INNER JOIN\'  => $forum_db->prefix . \'users AS u\',
  205.             \'ON\'          => \'u.id=p.poster_id\'
  206.         ),
  207.         array(
  208.             \'INNER JOIN\'  => $forum_db->prefix . \'groups AS g\',
  209.             \'ON\'          => \'g.g_id=u.group_id\'
  210.         ),
  211.         array(
  212.             \'LEFT JOIN\'       => $forum_db->prefix . \'online AS o\',
  213.             \'ON\'          => \'(o.user_id=u.id AND o.user_id!=1 AND o.idle=0)\'
  214.         ),
  215.     ),
  216.     \'ORDER BY\'    => \'a.rate \' . ($type == 1 ? \'ASC\' : \'DESC\'),
  217.     \'LIMIT\'       => 5,
  218.     \'PARAMS\'      => array(\'NO_PREFIX\' => 1)
  219. );
  220.  
  221. $result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
  222.  
  223. if (!$forum_db->num_rows($result)) {
  224.     message($lang_common[\'Bad request\']);
  225. } else {
  226.     define(\'FORUM_PAGE\', \'toprated\');
  227.     require FORUM_ROOT.\'header.php\';
  228.    
  229.     // START SUBST - <!-- forum_main -->
  230.     ob_start();
  231.     ?>
  232.     <div class="admin-menu gen-content">
  233.         <ul>
  234.             <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>
  235.             <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>
  236.         </ul>
  237.     </div>
  238.     <div class="admin-submenu gen-content">
  239.         <ul>
  240.             <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>
  241.             <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>
  242.             <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>
  243.         </ul>
  244.     </div>
  245.     <div class="main-content main-topic" id="forum1">
  246.         <?php
  247.             while ($cur_post = $forum_db->fetch_assoc($result)) {
  248.                 ++$forum_page[\'item_count\'];
  249.                 $forum_page[\'post_ident\'] = array();
  250.                 $forum_page[\'author_ident\'] = array();
  251.                 $forum_page[\'author_info\'] = array();
  252.                 $forum_page[\'post_options\'] = array();
  253.                 $forum_page[\'post_contacts\'] = array();
  254.                 $forum_page[\'post_actions\'] = array();
  255.                 $forum_page[\'message\'] = array();
  256.  
  257.                 // Generate the post heading
  258.                 $forum_page[\'post_ident\'][\'num\'] = \'<span class="post-num">\'.forum_number_format($forum_page[\'start_from\'] + $forum_page[\'item_count\']).\'</span>\';
  259.  
  260.                 if ($cur_post[\'poster_id\'] > 1)
  261.                     $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>\';
  262.                 else
  263.                     $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>\';
  264.  
  265.                 $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>\';
  266.  
  267.                 ($hook = get_hook(\'vt_row_pre_post_ident_merge\')) ? eval($hook) : null;
  268.  
  269.                 if (isset($user_data_cache[$cur_post[\'poster_id\']][\'author_ident\']))
  270.                     $forum_page[\'author_ident\'] = $user_data_cache[$cur_post[\'poster_id\']][\'author_ident\'];
  271.                 else
  272.                 {
  273.                     // Generate author identification
  274.                     if ($cur_post[\'poster_id\'] > 1)
  275.                     {
  276.                         if ($forum_config[\'o_avatars\'] == \'1\' && $forum_user[\'show_avatars\'] != \'0\')
  277.                         {
  278.                             $forum_page[\'avatar_markup\'] = generate_avatar_markup($cur_post[\'poster_id\']);
  279.  
  280.                             if (!empty($forum_page[\'avatar_markup\']))
  281.                                 $forum_page[\'author_ident\'][\'avatar\'] = \'<li class="useravatar">\'.$forum_page[\'avatar_markup\'].\'</li>\';
  282.                         }
  283.  
  284.                         $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>\';
  285.                         $forum_page[\'author_ident\'][\'usertitle\'] = \'<li class="usertitle"><span>\'.get_title($cur_post).\'</span></li>\';
  286.  
  287.                         if ($cur_post[\'is_online\'] == $cur_post[\'poster_id\'])
  288.                             $forum_page[\'author_ident\'][\'status\'] = \'<li class="userstatus"><span>\'.$lang_topic[\'Online\'].\'</span></li>\';
  289.                         else
  290.                             $forum_page[\'author_ident\'][\'status\'] = \'<li class="userstatus"><span>\'.$lang_topic[\'Offline\'].\'</span></li>\';
  291.                     }
  292.                     else
  293.                     {
  294.                         $forum_page[\'author_ident\'][\'username\'] = \'<li class="username"><strong>\'.forum_htmlencode($cur_post[\'username\']).\'</strong></li>\';
  295.                         $forum_page[\'author_ident\'][\'usertitle\'] = \'<li class="usertitle"><span>\'.get_title($cur_post).\'</span></li>\';
  296.                     }
  297.                 }
  298.  
  299.                 if (isset($user_data_cache[$cur_post[\'poster_id\']][\'author_info\']))
  300.                     $forum_page[\'author_info\'] = $user_data_cache[$cur_post[\'poster_id\']][\'author_info\'];
  301.                 else
  302.                 {
  303.                     // Generate author information
  304.                     if ($cur_post[\'poster_id\'] > 1)
  305.                     {
  306.                         if ($forum_config[\'o_show_user_info\'] == \'1\')
  307.                         {
  308.                             if ($cur_post[\'location\'] != \'\')
  309.                             {
  310.                                 if ($forum_config[\'o_censoring\'] == \'1\')
  311.                                     $cur_post[\'location\'] = censor_words($cur_post[\'location\']);
  312.  
  313.                                 $forum_page[\'author_info\'][\'from\'] = \'<li><span>\'.$lang_topic[\'From\'].\' <strong>\'.forum_htmlencode($cur_post[\'location\']).\'</strong></span></li>\';
  314.                             }
  315.  
  316.                             $forum_page[\'author_info\'][\'registered\'] = \'<li><span>\'.$lang_topic[\'Registered\'].\' <strong>\'.format_time($cur_post[\'registered\'], 1).\'</strong></span></li>\';
  317.  
  318.                             if ($forum_config[\'o_show_post_count\'] == \'1\' || $forum_user[\'is_admmod\'])
  319.                                 $forum_page[\'author_info\'][\'posts\'] = \'<li><span>\'.$lang_topic[\'Posts info\'].\' <strong>\'.forum_number_format($cur_post[\'num_posts\']).\'</strong></span></li>\';
  320.                         }
  321.  
  322.                         if ($forum_user[\'is_admmod\'])
  323.                         {
  324.                             if ($cur_post[\'admin_note\'] != \'\')
  325.                                 $forum_page[\'author_info\'][\'note\'] = \'<li><span>\'.$lang_topic[\'Note\'].\' <strong>\'.forum_htmlencode($cur_post[\'admin_note\']).\'</strong></span></li>\';
  326.                         }
  327.                     }
  328.                 }
  329.  
  330.                 // Generate IP information for moderators/administrators
  331.                 if ($forum_user[\'is_admmod\'])
  332.                     $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>\';
  333.  
  334.                 // Generate author contact details
  335.                 if ($forum_config[\'o_show_user_info\'] == \'1\')
  336.                 {
  337.                     if (isset($user_data_cache[$cur_post[\'poster_id\']][\'post_contacts\']))
  338.                         $forum_page[\'post_contacts\'] = $user_data_cache[$cur_post[\'poster_id\']][\'post_contacts\'];
  339.                     else
  340.                     {
  341.                         if ($cur_post[\'poster_id\'] > 1)
  342.                         {
  343.                             if ($cur_post[\'url\'] != \'\')
  344.                                 $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>\';
  345.                             if ((($cur_post[\'email_setting\'] == \'0\' && !$forum_user[\'is_guest\']) || $forum_user[\'is_admmod\']) && $forum_user[\'g_send_email\'] == \'1\')
  346.                                 $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>&#160;\'.forum_htmlencode($cur_post[\'username\']).\'</span></a></span>\';
  347.                             else if ($cur_post[\'email_setting\'] == \'1\' && !$forum_user[\'is_guest\'] && $forum_user[\'g_send_email\'] == \'1\')
  348.                                 $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>&#160;\'.forum_htmlencode($cur_post[\'username\']).\'</span></a></span>\';
  349.                         }
  350.                         else
  351.                         {
  352.                             if ($cur_post[\'poster_email\'] != \'\' && !$forum_user[\'is_guest\'] && $forum_user[\'g_send_email\'] == \'1\')
  353.                                 $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>&#160;\'.forum_htmlencode($cur_post[\'username\']).\'</span></a></span>\';
  354.                         }
  355.                     }
  356.  
  357.                     ($hook = get_hook(\'vt_row_pre_post_contacts_merge\')) ? eval($hook) : null;
  358.  
  359.                     if (!empty($forum_page[\'post_contacts\']))
  360.                         $forum_page[\'post_options\'][\'contacts\'] = \'<p class="post-contacts">\'.implode(\' \', $forum_page[\'post_contacts\']).\'</p>\';
  361.                 }
  362.  
  363.                 // Generate the post options links
  364.                 if (!$forum_user[\'is_guest\'])
  365.                 {
  366.                     $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>\';
  367.  
  368.                     if (!$forum_page[\'is_admmod\'])
  369.                     {
  370.                         if ($cur_topic[\'closed\'] == \'0\')
  371.                         {
  372.                             if ($cur_post[\'poster_id\'] == $forum_user[\'id\'])
  373.                             {
  374.                                 if (($forum_page[\'start_from\'] + $forum_page[\'item_count\']) == 1 && $forum_user[\'g_delete_topics\'] == \'1\')
  375.                                     $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>\';
  376.                                 if (($forum_page[\'start_from\'] + $forum_page[\'item_count\']) > 1 && $forum_user[\'g_delete_posts\'] == \'1\')
  377.                                     $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>\';
  378.                                 if ($forum_user[\'g_edit_posts\'] == \'1\')
  379.                                     $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>\';
  380.                             }
  381.  
  382.                             if (($cur_topic[\'post_replies\'] == \'\' && $forum_user[\'g_post_replies\'] == \'1\') || $cur_topic[\'post_replies\'] == \'1\')
  383.                                 $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>\';
  384.                         }
  385.                     }
  386.                     else
  387.                     {
  388.                         if (($forum_page[\'start_from\'] + $forum_page[\'item_count\']) == 1)
  389.                             $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>\';
  390.                         else
  391.                             $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>\';
  392.  
  393.                         $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>\';
  394.                         $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>\';
  395.                     }
  396.                 }
  397.                 else
  398.                 {
  399.                     if ($cur_topic[\'closed\'] == \'0\')
  400.                     {
  401.                         if (($cur_topic[\'post_replies\'] == \'\' && $forum_user[\'g_post_replies\'] == \'1\') || $cur_topic[\'post_replies\'] == \'1\')
  402.                             $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>\';
  403.                     }
  404.                 }
  405.  
  406.                 ($hook = get_hook(\'vt_row_pre_post_actions_merge\')) ? eval($hook) : null;
  407.  
  408.                 if (!empty($forum_page[\'post_actions\']))
  409.                     $forum_page[\'post_options\'][\'actions\'] = \'<p class="post-actions">\'.implode(\' \', $forum_page[\'post_actions\']).\'</p>\';
  410.  
  411.                 // Give the post some class
  412.                 $forum_page[\'item_status\'] = array(
  413.                     \'post\',
  414.                     ($forum_page[\'item_count\'] % 2 != 0) ? \'odd\' : \'even\'
  415.                 );
  416.  
  417.                 if ($forum_page[\'item_count\'] == 1)
  418.                     $forum_page[\'item_status\'][\'firstpost\'] = \'firstpost\';
  419.  
  420.                 if (($forum_page[\'start_from\'] + $forum_page[\'item_count\']) == $forum_page[\'finish_at\'])
  421.                     $forum_page[\'item_status\'][\'lastpost\'] = \'lastpost\';
  422.  
  423.                 if ($cur_post[\'id\'] == $cur_topic[\'first_post_id\'])
  424.                     $forum_page[\'item_status\'][\'topicpost\'] = \'topicpost\';
  425.                 else
  426.                     $forum_page[\'item_status\'][\'replypost\'] = \'replypost\';
  427.  
  428.  
  429.                 // Generate the post title
  430.                 if ($cur_post[\'id\'] == $cur_topic[\'first_post_id\'])
  431.                     $forum_page[\'item_subject\'] = sprintf($lang_topic[\'Topic title\'], $cur_topic[\'subject\']);
  432.                 else
  433.                     $forum_page[\'item_subject\'] = sprintf($lang_topic[\'Reply title\'], $cur_topic[\'subject\']);
  434.  
  435.                 $forum_page[\'item_subject\'] = forum_htmlencode($forum_page[\'item_subject\']);
  436.  
  437.                 // Perform the main parsing of the message (BBCode, smilies, censor words etc)
  438.                 $forum_page[\'message\'][\'message\'] = parse_message($cur_post[\'message\'], $cur_post[\'hide_smilies\']);
  439.  
  440.                 if ($cur_post[\'edited\'] != \'\')
  441.                     $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>\';
  442.  
  443.                 // Do signature parsing/caching
  444.                 if ($cur_post[\'signature\'] != \'\' && $forum_user[\'show_sig\'] != \'0\' && $forum_config[\'o_signatures\'] == \'1\')
  445.                 {
  446.                     if (!isset($signature_cache[$cur_post[\'poster_id\']]))
  447.                         $signature_cache[$cur_post[\'poster_id\']] = parse_signature($cur_post[\'signature\']);
  448.  
  449.                     $forum_page[\'message\'][\'signature\'] = \'<div class="sig-content"><span class="sig-line"><!-- --></span>\'.$signature_cache[$cur_post[\'poster_id\']].\'</div>\';
  450.                 }
  451.                 ?>
  452.                 <div class="<?php echo implode(\' \', $forum_page[\'item_status\']) ?>">
  453.                     <div id="p<?php echo $cur_post[\'id\'] ?>" class="posthead">
  454.                         <h3 class="hn post-ident"><?php echo implode(\' \', $forum_page[\'post_ident\']) ?></h3>
  455.                     </div>
  456.                     <div class="postbody<?php echo ($cur_post[\'is_online\'] == $cur_post[\'poster_id\']) ? \' online\' : \'\' ?>">
  457.                         <div class="post-author">
  458.                             <ul class="author-ident">
  459.                                 <?php echo implode("\n\t\t\t\t\t\t", $forum_page[\'author_ident\'])."\n" ?>
  460.                             </ul>
  461.                             <ul class="author-info">
  462.                                 <?php echo implode("\n\t\t\t\t\t\t", $forum_page[\'author_info\'])."\n" ?>
  463.                             </ul>
  464.                         </div>
  465.                         <div class="post-entry">
  466.                             <h4 id="pc<?php echo $cur_post[\'id\'] ?>" class="entry-title hn"><?php echo $forum_page[\'item_subject\'] ?></h4>
  467.                             <div class="entry-content">
  468.                                 <?php echo implode("\n\t\t\t\t\t\t", $forum_page[\'message\'])."\n" ?>
  469.                             </div>
  470.                         </div>
  471.                     </div>
  472.                     <div class="postfoot">
  473.                         <div class="post-options">
  474.                             <?php
  475.                                 AR_getRating($cur_post[\'id\'], $forum_page[\'post_options\'], $forum_user[\'is_guest\']);
  476.                                 echo implode("\n\t\t\t\t\t", $forum_page[\'post_options\'])."\n";
  477.                             ?>
  478.                         </div>
  479.                     </div>
  480.                 </div>
  481.                 <?php
  482.             }
  483.         ?>
  484.     </div>
  485.     <?php
  486.     $tpl_temp = forum_trim(ob_get_contents());
  487.     $tpl_main = str_replace(\'<!-- forum_main -->\', $tpl_temp, $tpl_main);
  488.     ob_end_clean();
  489.     // END SUBST - <!-- forum_main -->
  490.    
  491.     require FORUM_ROOT.\'footer.php\';
  492. }
  493. ?>
  494.             ';
  495.            
  496.             $fp = fopen($toprated, 'w');
  497.             fwrite($fp, $tr_contents);
  498.             fclose($fp);
  499.         }
  500.     ]]></install>
  501.  
  502.     <uninstall><![CDATA[
  503.         $forum_db->drop_table('postrating');   
  504.         $forum_db->drop_table('postrating_det');
  505.        
  506.         $query_conf = array(
  507.             'DELETE'    => 'config',
  508.             'WHERE'     => 'conf_name="p_ajax_rating_type"'
  509.         );
  510.         $forum_db->query_build($query_conf);
  511.        
  512.         $query_conf = array(
  513.             'DELETE'    => 'config',
  514.             'WHERE'     => 'conf_name="p_ajax_rating_allow_multiple"'
  515.         );
  516.         $forum_db->query_build($query_conf);
  517.        
  518.         $query_conf = array(
  519.             'DELETE'    => 'config',
  520.             'WHERE'     => 'conf_name="p_ajax_rating_allow_guest"'
  521.         );
  522.         $forum_db->query_build($query_conf);
  523.        
  524.         $toprated = FORUM_ROOT . 'toprated.php';
  525.         if (is_file($toprated)) {
  526.             unlink($toprated);
  527.         }
  528.     ]]></uninstall>
  529.  
  530.     <hooks>
  531.         <hook id="hd_head"><![CDATA[
  532.             if (FORUM_PAGE == 'viewtopic' || FORUM_PAGE == 'toprated') {
  533.                 require_once FORUM_ROOT.'include/parser.php';
  534.                 $forum_head['style_ajax_rating'] = '<link rel="stylesheet" type="text/css" media="screen" href="'.$ext_info['url'].'/ajax_rating.css" />';
  535.                 $forum_head['prototypejs'] = '<script type="text/javascript" src="'.$ext_info['url'].'/js/prototype.js"></script>';
  536.                 $forum_head['js_ajax_rating'] = '<script type="text/javascript" src="'.$ext_info['url'].'/js/ajax_rating.js?baseUri='.$base_url.'/&amp;extUri='.$ext_info['url'].'"></script>';
  537.             }
  538.         ]]></hook>
  539.         <hook id="vt_start, mi_start"><![CDATA[
  540.             include_once $ext_info['path'].'/fns.php';
  541.         ]]></hook>
  542.         <hook id="vt_row_pre_display"><![CDATA[
  543.             AR_getRating($cur_post['id'], $forum_page['post_options'], $forum_user['is_guest']);
  544.         ]]></hook>
  545.         <hook id="mi_new_action"><![CDATA[
  546.             AR_processRequest($action);
  547.         ]]></hook>
  548.         <hook id="co_modify_url_scheme"><![CDATA[
  549.         // disable token validation for chat submit
  550.         if(preg_match('/(.*)\/misc.php\?action\=ajax_rating$/', get_current_url(), $m)) {
  551.             if (is_array($m)) {
  552.                 $_POST['csrf_token'] = generate_form_token($m[1].'/misc.php?action=ajax_rating');
  553.             } else {
  554.                 $_POST['csrf_token'] = generate_form_token($base_url.'/misc.php?action=ajax_rating');
  555.             }
  556.         }
  557.         ]]></hook>
  558.         <hook id="aop_features_pre_header_load"><![CDATA[
  559.             if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php'))
  560.                 include_once $ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php';
  561.             else
  562.                 include_once $ext_info['path'].'/lang/English/'.$ext_info['id'].'.php';
  563.         ]]></hook>
  564.         <hook id="aop_features_validation"><![CDATA[
  565.             if (!isset($form['ajax_rating_type']) || $form['ajax_rating_type'] != '1') $form['ajax_rating_type'] = '0';
  566.             if (!isset($form['ajax_rating_allow_guest']) || $form['ajax_rating_allow_guest'] != '1') $form['ajax_rating_allow_guest'] = '0';
  567.             if (!isset($form['ajax_rating_allow_multiple']) || $form['ajax_rating_allow_multiple'] != '1') $form['ajax_rating_allow_multiple'] = '0';
  568.         ]]></hook>
  569.         <hook id="aop_features_avatars_fieldset_end"><![CDATA[
  570.             ?>
  571.                     <div class="content-head">
  572.                         <h2 class="hn"><span><?php echo $lang_ajax_rating['Settings header'] ?></span></h2>
  573.                     </div>                 
  574.                     <fieldset class="frm-group group1">
  575.             <?php
  576.                         if (defined('AR_DEBUG_MODE')) {
  577.             ?>
  578.                         <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
  579.                             <div class="sf-box checkbox">
  580.                                 <span class="fld-input">
  581.                                     <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"' ?>/>
  582.                                 </span>
  583.                                 <label for="fld<?php echo ++$forum_page['fld_count'] ?>">
  584.                                     <span><?php echo $lang_ajax_rating['Rating type'] ?></span>
  585.                                 </label>
  586.                             </div>
  587.                         </div>
  588.             <?php
  589.                         }
  590.             ?>
  591.                         <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
  592.                             <div class="sf-box checkbox">
  593.                                 <span class="fld-input">
  594.                                     <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"' ?>/>
  595.                                 </span>
  596.                                 <label for="fld<?php echo ++$forum_page['fld_count'] ?>">
  597.                                     <span><?php echo $lang_ajax_rating['Multiple rates'] ?></span>
  598.                                 </label>
  599.                             </div>
  600.                         </div>
  601.                         <div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
  602.                             <div class="sf-box checkbox">
  603.                                 <span class="fld-input">
  604.                                     <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"' ?>/>
  605.                                 </span>
  606.                                 <label for="fld<?php echo ++$forum_page['fld_count'] ?>">
  607.                                     <span><?php echo $lang_ajax_rating['Allow guest'] ?></span>
  608.                                 </label>
  609.                             </div>
  610.                         </div>
  611.                     </fieldset>
  612.             <?php
  613.  
  614.         ]]></hook>
  615.         <hook id="fn_generate_navlinks_end"><![CDATA[
  616.             if (!$lang_ajax_rating) {
  617.                 if (file_exists($ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php'))
  618.                     include_once $ext_info['path'].'/lang/'.$forum_user['language'].'/'.$ext_info['id'].'.php';
  619.                 else
  620.                     include_once $ext_info['path'].'/lang/English/'.$ext_info['id'].'.php';
  621.             }
  622.             $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>';
  623.         ]]></hook>
  624.     </hooks>
  625. </extension>
Add Comment
Please, Sign In to add comment