commit d85d01f238fdccf03e1a87e7fd430ab20f562126 Author: SVarlamov Date: Sun Jun 12 16:59:51 2016 +0300 Добавлен Модуль Опросы | Голосование diff --git a/README.md b/README.md new file mode 100644 index 0000000..4b77bc5 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +## poll + +# Модуль Опросы/Голосование v1.1a + + +## Данный модуль предназачен для организации системы опросов на сайте. + + * Возможности модуля позволяют создавать неограниченное количество опросных листов, а также неограниченное количество вопросов. + * Добавить в .htaccess
+ + ```php + ## Poll
+ RewriteRule ^poll-([0-9]+).html$ index.php?module=poll&action=result&pid=$1
+ RewriteRule ^pollcomment-([0-9]+).html$ index.php?module=poll&action=form&pop=1&pid=$1
+ RewriteRule ^poll-archive.html$ index.php?module=poll&action=archive
+ ``` + +## Перед копированием модуля в папку modules, удалите файл README.md, копируйте только корневую папку poll со всем ее содержимым внутри! + +## Changelog: + +22.09.2013 - версия 1.1a \ No newline at end of file diff --git a/ReadMe.txt b/ReadMe.txt new file mode 100644 index 0000000..a1834cf --- /dev/null +++ b/ReadMe.txt @@ -0,0 +1,7 @@ + .htaccess + + + ## Poll + RewriteRule ^poll-([0-9]+).html$ index.php?module=poll&action=result&pid=$1 + RewriteRule ^pollcomment-([0-9]+).html$ index.php?module=poll&action=form&pop=1&pid=$1 + RewriteRule ^poll-archive.html$ index.php?module=poll&action=archive \ No newline at end of file diff --git a/admin/admin_comments.tpl b/admin/admin_comments.tpl new file mode 100644 index 0000000..699aea4 --- /dev/null +++ b/admin/admin_comments.tpl @@ -0,0 +1,78 @@ +
{#POLL_COMMENTS_TITLE#}
+ +
+
+ {#POLL_COMMENTS_INFO#} +
+
+ + + + +
+
+
{#POLL_COMMENTS_TITLE#}
+ +
+ +
+ + + + + + + + + + + + {foreach from=$items item=item} + + + + + + {/foreach} + + + + +
{#POLL_COMMENT_INFO#}{#POLL_COMMENT_TITLE#}
+ + + {#POLL_COMMENT_AUTHOR#}
+ {$item->poll_comment_author|escape} +
+
+ {#POLL_COMMENT_DATE#}
+ {$item->poll_comment_time|date_format:$DATE_FORMAT|pretty_date} +
+
+ Тема +
+ Комментарий + +
+
+ +
+
+
+ +{if $page_nav} + +{/if} \ No newline at end of file diff --git a/admin/admin_fields.tpl b/admin/admin_fields.tpl new file mode 100644 index 0000000..5b2abf0 --- /dev/null +++ b/admin/admin_fields.tpl @@ -0,0 +1,299 @@ + + + + + +{if $smarty.request.moduleaction == 'new'} +
{#POLL_ADD_POLL#}
+ +
+
+ {#POLL_NEW_INFO#} +
+
+{else} +
{#POLL_EDIT#}
+ +
+
+ {#POLL_EDIT_INFO#} +
+
+{/if} + + + + +
+ +
+
+
{if $smarty.request.id != ''}{#POLL_EDIT#}{else}{#POLL_ADD_POLL#}{/if}
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
{#POLL_NAME#}: +
+
{#POLL_STATUS#}? + poll_status==1}checked{/if} value="1"/> + poll_status==0}checked{/if} value="0" /> +
{#POLL_CAN_COMMENT#} + poll_can_comment==1}checked{/if} /> + poll_can_comment==0}checked{/if} /> +
{#POLL_START_TIME#} + + {#POLL_END_TIME#} + +
{#POLL_USER_GROUPS#}
{#POLL_GROUP_INFO#}
+ +
+ + {if $smarty.request.id != ''} +
+
+
+
{#POLL_QUESTIONS#}
+
+ + + + + + + + + + + + + + + + + + {if $items} + {foreach from=$items item=item} + + + + + + + + {/foreach} + {else} + + + + {/if} + +
{#POLL_QUESTION_NAME#}{#POLL_QUESTION_COLOR#} {#POLL_QUESTION_HITS#}
+ + +
+
+
+
+ + + +
+
    +
  • {#POLL_QUESTION_NO_ITEMS#}
  • +
+
+ + {/if} +
+ +
+
+
+ +{if $smarty.request.id != ''} +
+
+
{#POLL_QUESTIONS_ADD#}
+
+
+ + + + + + + + + + + + + + + + + + + + + +
{#POLL_QUESTION_NAME#}{#POLL_QUESTION_COLOR#} {#POLL_QUESTION_HITS#}
+
+
+ + + +
+
+
+{/if} \ No newline at end of file diff --git a/admin/admin_forms.tpl b/admin/admin_forms.tpl new file mode 100644 index 0000000..100de9a --- /dev/null +++ b/admin/admin_forms.tpl @@ -0,0 +1,102 @@ +
{#POLL_MODULE_NAME#}
+ +
+
+ {#POLL_MODULE_TITLE#} +
+
+ + + + +
+
+
{#POLL_MODULE_ALL#}
+ +
+ + + + + + + + + {if $items} + + + + + + + + + + + + {foreach from=$items item=item} + + + + + + + + + + + + + + + + {/foreach} + {else} + + + + {/if} +
[!]{#POLL_NAME#}{#POLL_SYSTEM_TAG#}{#POLL_START_END#}{#POLL_HITS_CMMENT#}{#POLL_ACTIONS#}
+ {if $item->poll_status != '1'} + + {else} + + {/if} + + {$item->poll_title} + +
+
+ c {$item->poll_start|date_format:$TIME_FORMAT|pretty_date} +
+ по {$item->poll_end|date_format:$TIME_FORMAT|pretty_date} +
+ {if $item->sum_hits == ''} 0 {else} {$item->sum_hits} {/if} / {$item->comments} + + + + +
+
    +
  • {#POLL_MODULE_NO_ITEMS#}
  • +
+
+
+ + +{if $page_nav} + +{/if} \ No newline at end of file diff --git a/admin/js/color.png b/admin/js/color.png new file mode 100644 index 0000000..809fb00 Binary files /dev/null and b/admin/js/color.png differ diff --git a/admin/js/iColorPicker.js b/admin/js/iColorPicker.js new file mode 100644 index 0000000..42cde4c --- /dev/null +++ b/admin/js/iColorPicker.js @@ -0,0 +1 @@ +var imageUrl = '/modules/poll/admin/js/color.png'; function iColorShow(id, id2) { var eICP = jQuery("#" + id2).position(); jQuery("#iColorPicker").css({ 'top': eICP.top + (jQuery("#" + id).outerHeight()) + "px", 'left': (eICP.left-200) + "px", 'position': 'absolute' }).fadeIn("fast"); jQuery("#iColorPickerBg").css({ 'position': 'fixed', 'top': 0, 'left': 0, 'width': '100%', 'height': '100%' }).fadeIn("fast"); var def = jQuery("#" + id).val(); jQuery('#colorPreview span').text(def); jQuery('#colorPreview').css('background', def); jQuery('#color').val(def); var hxs = jQuery('#iColorPicker'); for (i = 0; i < hxs.length; i++) { var tbl = document.getElementById('hexSection' + i); var tblChilds = tbl.childNodes; for (j = 0; j < tblChilds.length; j++) { var tblCells = tblChilds[j].childNodes; for (k = 0; k < tblCells.length; k++) { jQuery(tblChilds[j].childNodes[k]).unbind().mouseover(function(a) { var aaa = "#" + jQuery(this).attr('hx'); jQuery('#colorPreview').css('background', aaa); jQuery('#colorPreview span').text(aaa) }).click(function() { var aaa = "#" + jQuery(this).attr('hx'); jQuery("#" + id).val(aaa).css("background", aaa); jQuery("#iColorPickerBg").hide(); jQuery("#iColorPicker").fadeOut(); jQuery(this) }) } } } } this.iColorPicker = function() { jQuery("input.iColorPicker").each(function(i) { if (i == 0) { jQuery(document.createElement("div")).attr("id", "iColorPicker").css('display', 'none').html('
').appendTo("body"); jQuery(document.createElement("div")).attr("id", "iColorPickerBg").click(function() { jQuery("#iColorPickerBg").hide(); jQuery("#iColorPicker").fadeOut() }).appendTo("body"); jQuery('table.pickerTable td').css({ 'width': '12px', 'height': '14px', 'border': '1px solid #000', 'cursor': 'pointer' }); jQuery('#iColorPicker table.pickerTable').css({ 'border-collapse': 'collapse' }); jQuery('#iColorPicker').css({ 'border': '1px solid #ccc', 'background': '#333', 'padding': '5px', 'color': '#fff', 'z-index': 9999 }) } jQuery('#colorPreview').css({ 'height': '50px' }); jQuery(this).css("backgroundColor", jQuery(this).val()).after('') }) }; jQuery(function() { iColorPicker() }) \ No newline at end of file diff --git a/class.poll.php b/class.poll.php new file mode 100644 index 0000000..67d1bc2 --- /dev/null +++ b/class.poll.php @@ -0,0 +1,938 @@ +config_load($lang_file, 'showpoll'); + + $row = $AVE_DB->Query(" + SELECT + poll.*, + SUM(itm.poll_item_hits) AS sumhits + FROM + " . PREFIX . "_module_poll AS poll + LEFT JOIN + " . PREFIX . "_module_poll_items AS itm + ON poll_id = poll.id + WHERE + poll.id = '" . $pid . "' AND + poll.poll_title != '' AND + poll.poll_status = '1' AND + poll.poll_start < '" . time() . "' + GROUP BY poll.id + ")->FetchRow(); + + if (!$row) return; + + $poll_groups_id = empty($row->poll_groups_id) ? array() : explode(',', $row->poll_groups_id); + $poll_users_id = empty($row->poll_users_id) ? array() : explode(',', $row->poll_users_id); + $poll_users_ip = empty($row->poll_users_ip) ? array() : explode(',', $row->poll_users_ip); + + $current_user_ip = empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR']; + + if (@in_array($current_user_ip, $poll_users_ip) || + @in_array($_SESSION['user_id'], $poll_users_id) || + (isset($_COOKIE['poll_' . $pid]) && $_COOKIE['poll_' . $pid] == '1') ) + { + $row->message = $AVE_Template->get_config_vars('POLL_ALREADY_POLL'); + } + elseif (!(@in_array(UGROUP, $poll_groups_id))) + { + $row->message = $AVE_Template->get_config_vars('POLL_NO_PERMISSION'); + } + elseif ($row->poll_end < time()) + { + $row->message = $AVE_Template->get_config_vars('POLL_EXPIRED'); + } + + $items = array(); + $sql = $AVE_DB->Query(" + SELECT + *, + " . ($row->sumhits > 0 ? 'ROUND(poll_item_hits*100/' . $row->sumhits . ')' : 0) . " AS sum + FROM " . PREFIX . "_module_poll_items + WHERE poll_id = '" . $pid . "' + ORDER BY poll_item_position ASC + "); + while ($row_items = $sql->FetchRow()) + { + array_push($items, $row_items); + } + + $AVE_Template->assign('formaction', 'index.php?module=poll&action=vote&pid=' . $pid); + $AVE_Template->assign('formaction_result', $this->_pollLinkRewrite('index.php?module=poll&action=result&pid=' . $pid)); + $AVE_Template->assign('formaction_archive', $this->_pollLinkRewrite('index.php?module=poll&action=archive')); + + $AVE_Template->assign('poll', $row); + $AVE_Template->assign('items', $items); + + if (isset($row->message)) + { + $AVE_Template->display($tpl_dir . 'poll_nav_result.tpl'); + } + else + { + $AVE_Template->display($tpl_dir . 'poll_nav.tpl'); + } + } + + /** + * Учет результатов опроса + * + * @param int $pid идентификатор опроса + */ + function pollVote($pid) + { + global $AVE_DB; + + $row = $AVE_DB->Query(" + SELECT * + FROM " . PREFIX . "_module_poll + WHERE id = '" . $pid . "' + ")->FetchRow(); + + $poll_groups_id = empty($row->poll_groups_id) ? array() : explode(',', $row->poll_groups_id); + $poll_users_id = empty($row->poll_users_id) ? array() : explode(',', $row->poll_users_id); + $poll_users_ip = empty($row->poll_users_ip) ? array() : explode(',', $row->poll_users_ip); + + $current_user_ip = empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR']; + + $back = $this->_pollLinkRewrite('index.php?module=poll&action=result&pid=' . $pid); + + if (!(@in_array(UGROUP, $poll_groups_id))) + { + header('Location:' . $back); + exit; + } + + if (@in_array($current_user_ip, $poll_users_ip) || + @in_array($_SESSION['user_id'], $poll_users_id) || + $_COOKIE['poll_' . $pid] == '1') + { + header('Location:' . $back); + exit; + } + + setcookie('poll_' . $pid, '1', time() + 3600 * 3600); + + $AVE_DB->Query(" + UPDATE " . PREFIX . "_module_poll_items + SET poll_item_hits = poll_item_hits + 1 + WHERE id = '" . (int)$_POST['p_item'] . "' + "); + + $AVE_DB->Query(" + UPDATE " . PREFIX . "_module_poll + SET + poll_users_ip = CONCAT_WS(',', poll_users_ip, '" . $current_user_ip . "') + " . ((UGROUP != 2) ? ", poll_users_id = CONCAT_WS(',', poll_users_id, '" . $_SESSION['user_id'] . "')" : '') . " + WHERE + id = '" . $pid . "' + "); + + header('Location:' . $back); + exit; + } + + /** + * Подробная информация и статистика опроса, комментарии пользователей + * + * @param string $tpl_dir путь к папке с шаблонами модуля + * @param string $lang_file путь к языковому файлу модуля + * @param int $pid идентификатор опроса + */ + function pollResultShow($tpl_dir, $lang_file, $pid) + { + global $AVE_DB, $AVE_Template; + + $AVE_Template->config_load($lang_file, 'showresult'); + + if (isset($_REQUEST['sub']) && $_REQUEST['sub'] == 'new') + { + $errors = $this->pollCommentNew($pid); + + if (sizeof($errors) == 0) + { + header('Location:' . $this->_pollLinkRewrite('index.php?module=poll&action=result&pid=' . $pid)); + exit; + } + + $AVE_Template->assign('errors', $errors); + } + + $poll = $AVE_DB->Query(" + SELECT + poll.*, + SUM(itm.poll_item_hits) AS votes + FROM + " . PREFIX . "_module_poll AS poll + LEFT JOIN + " . PREFIX . "_module_poll_items AS itm + ON poll_id = poll.id + WHERE + poll.id = '" . $pid . "' AND + poll.poll_title != '' AND + poll.poll_status = '1' AND + poll.poll_start < '" . time() . "' + GROUP BY poll.id + ")->FetchRow(); + + if ($poll === false) return; + + $items = array(); + $sql = $AVE_DB->Query(" + SELECT + *, + " . ($poll->votes > 0 ? 'ROUND(poll_item_hits*100/' . $poll->votes . ')' : 0) . " AS sum + FROM " . PREFIX . "_module_poll_items + WHERE poll_id = '" . $pid . "' + ORDER BY poll_item_position ASC + "); + while ($row_items = $sql->FetchRow()) + { + array_push($items, $row_items); + } + + if ($poll->poll_can_comment == 1) + { + //include_once(BASE_DIR . '/lib/markitup/sets/bbcode/markitup.bbcode-parser.php'); + + $comments = array(); + $sql = $AVE_DB->Query(" + SELECT + cmnt.*, + IFNULL(firstname, '') AS firstname, + IFNULL(lastname, '" . $AVE_Template->get_config_vars('POLL_GUEST') . "') AS lastname + FROM + " . PREFIX . "_module_poll_comments AS cmnt + LEFT JOIN + " . PREFIX . "_users AS usr + ON usr.Id = cmnt.poll_comment_author_id + WHERE poll_id = '" . $pid . "' + ORDER BY poll_comment_time DESC + "); + while ($row_comments = $sql->FetchRow()) + { + $row_comments->poll_comment_text = $row_comments->poll_comment_text; + + array_push($comments, $row_comments); + } + + $poll->count_comments = $sql->NumRows(); + } + + $poll_users_id = empty($poll->poll_users_id) ? array() : explode(',', $poll->poll_users_id); + $poll_users_ip = empty($poll->poll_users_ip) ? array() : explode(',', $poll->poll_users_ip); + + $current_user_ip = empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR']; + + $is_vote = 1; + if (@in_array($current_user_ip, $poll_users_ip) || + @in_array($_SESSION['user_id'], $poll_users_id) || + (isset($_COOKIE['poll_' . $pid]) && $_COOKIE['poll_' . $pid] == '1')) + { + $is_vote = 0; + } + + $rights = 0; + $groups = array(); + if ($poll->poll_groups_id != '') + { + $sql = $AVE_DB->Query(" + SELECT + user_group, + user_group_name + FROM + " . PREFIX . "_user_groups + WHERE + user_group IN(" . $poll->poll_groups_id . ") + "); + while ($row_g = $sql->FetchRow()) + { + if (UGROUP == $row_g->user_group) $rights = 1; + array_push($groups, $row_g->user_group_name); + } + } + + $poll->can_vote = ($is_vote == 1 && $rights == 1) ? 1 : 0; + $poll->groups = implode(', ', $groups); + $poll->can_comment = ($poll->poll_status == 1 && $poll->poll_can_comment == 1 && $rights == 1) ? 1 : 0; + $poll->anti_spam = ($this->_antispam == 1 && function_exists('imagettftext') && function_exists('imagejpeg')) ? 1 : 0; + $poll->comment_max_chars = $this->_commentwords; + $poll->items = $items; + $poll->comments = $comments; + $poll->formaction = 'index.php?module=poll&action=vote&pid=' . $pid; + $poll->link_result = $this->_pollLinkRewrite('index.php?module=poll&action=result&pid=' . $pid); +// $poll->link_archive = $this->_pollLinkRewrite('index.php?module=poll&action=archive'); +// $poll->link_comment = $this->_pollLinkRewrite('index.php?module=poll&action=form&pop=1&pid=' . $pid); + + $AVE_Template->assign('poll', $poll); + + define('MODULE_SITE', $AVE_Template->get_config_vars('POLL_PAGE_TITLE_PREFIX') . $poll->poll_title); + define('MODULE_CONTENT', $AVE_Template->fetch($tpl_dir . 'result.tpl')); + } + + /** + * Список завершенных и действующих опросов + * + * @param string $tpl_dir путь к папке с шаблонами модуля + * @param string $lang_file путь к языковому файлу модуля + */ + function pollArchiveShow($tpl_dir, $lang_file) + { + global $AVE_DB, $AVE_Template; + + if (empty($_REQUEST['order'])) + { + $order = 'poll_title'; + } + else + { + switch ($_REQUEST['order']) + { + case 'title': + $order = 'poll_title'; + break; + + case 'start': + $order = 'poll_start'; + break; + + case 'end': + $order = 'poll_end'; + break; + + case 'votes': + $order = 'votes'; + break; + + default: + $order = 'poll_title'; + break; + } + } + + if (isset($_REQUEST['by']) && $_REQUEST['by'] == 'desc') + { + $order .= ' DESC'; + } + else + { + $order .= ' ASC'; + } + + $items = array(); + $sql = $AVE_DB->Query(" + SELECT + poll.id, + poll.poll_title, + poll.poll_start, + poll.poll_end, + SUM(itm.poll_item_hits) AS votes + FROM + " . PREFIX . "_module_poll AS poll + LEFT JOIN + " . PREFIX . "_module_poll_items AS itm + ON poll_id = poll.id + WHERE + poll.poll_title != '' AND + poll.poll_status = '1' AND + poll.poll_start < '" . time() . "' + GROUP BY poll.id + ORDER BY " . $order + ); + while ($row = $sql->FetchRow()) + { + $row->plink = $this->_pollLinkRewrite('index.php?module=poll&action=result&pid=' . $row->id); + array_push($items, $row); + } + + $AVE_Template->assign('items', $items); + $AVE_Template->config_load($lang_file, 'showarchive'); + + define('MODULE_SITE', $AVE_Template->get_config_vars('POLL_ARCHIVE_TITLE')); + define('MODULE_CONTENT', $AVE_Template->fetch($tpl_dir . 'archive.tpl')); + } + + /** + * Метод отображения комментариев + * + * @param string $tpl_dir путь к папке с шаблонами модуля + * @param string $lang_file путь к языковому файлу модуля + * @param ini $pid идентификатор опроса + * @param string $theme + * @param string $errors + * @param string $text + * @param string $title + */ + function pollCommentShow($tpl_dir, $lang_file, $pid, $theme, $errors='', $text='', $title='') + { + global $AVE_DB, $AVE_Template; + + $AVE_Template->config_load($lang_file, 'displayform'); + + $row = $AVE_DB->Query(" + SELECT * + FROM " . PREFIX . "_module_poll + WHERE id = '" . $pid . "' + LIMIT 1 + ")->FetchRow(); + $groups = explode(',', $row->poll_groups_id); + + if ($row->poll_status == 1 && $row->poll_can_comment == 1 && in_array(UGROUP, $groups)) + { + $AVE_Template->assign('cancomment', 1); + } + $AVE_Template->assign('max_chars', $this->_commentwords); + + if ($this->_antispam == 1 && function_exists('imagettftext') && function_exists('imagejpeg')) + { + $AVE_Template->assign('anti_spam', 1); + } + + if (!empty($errors)) $AVE_Template->assign('errors', $errors); + + $AVE_Template->assign('theme_folder', $theme); + $AVE_Template->assign('title', $title); + $AVE_Template->assign('text', $text); + $AVE_Template->display($tpl_dir . 'poll_form.tpl'); + } + + /** + * Метод создания нового комментария + * + * @param string $tpl_dir путь к папке с шаблонами модуля + * @param string $lang_file путь к языковому файлу модуля + * @param int $pid идентификатор опроса + */ + function pollCommentNew($pid) + { + global $AVE_DB, $AVE_Template; + + $errors = array(); + + if (isset($_REQUEST['ajax']) && $_REQUEST['ajax'] == 1) + { + $comment_title = iconv('utf-8', 'cp1251', $_POST['comment_title']); + $comment_text = iconv('utf-8', 'cp1251', $_POST['comment_text']); + } + else + { + $comment_title = $_POST['comment_title']; + $comment_text = $_POST['comment_text']; + } + + $text = (mb_strlen($comment_text) > $this->_commentwords) + ? mb_substr($comment_text, 0, $this->_commentwords) . '...' + : $comment_text; + + if (mb_strlen($text) <= 10) $errors[] = $AVE_Template->get_config_vars('POLL_ENTER_TEXT'); + if (empty($comment_title)) $errors[] = $AVE_Template->get_config_vars('POLL_ENTER_TITLE'); + + if ($this->_antispam == 1) + { + if (! (isset($_SESSION['captcha_keystring']) && isset($_POST['securecode']) + && $_SESSION['captcha_keystring'] == $_POST['securecode'])) + { + $errors[] = $AVE_Template->get_config_vars('POLL_ENTER_CODE'); + } + + unset($_SESSION['captcha_keystring']); + } + + if (sizeof($errors) == 0) + { + $poll_groups_id = $AVE_DB->Query(" + SELECT poll_groups_id + FROM " . PREFIX . "_module_poll + WHERE id = '" . $pid . "' + AND poll_status = '1' + AND poll_can_comment = '1' + ")->GetCell(); + + if (!empty($poll_groups_id) && in_array(UGROUP, explode(',', $poll_groups_id))) + { + $author_id = isset($_SESSION['user_id']) ? $_SESSION['user_id'] : 0; + $author_ip = empty($_SERVER['REMOTE_ADDR']) ? '' : $_SERVER['REMOTE_ADDR']; + + $AVE_DB->Query(" + INSERT " . PREFIX . "_module_poll_comments + SET + poll_id = '" . $pid . "', + poll_comment_time = '" . time() . "', + poll_comment_author_id = '" . $author_id . "', + poll_comment_author_ip = '" . $author_ip . "', + poll_comment_title = '" . $comment_title . "', + poll_comment_text = '" . $text . "' + "); + + return $errors; + } + + $errors[] = $AVE_Template->get_config_vars('POLL_ERROR_PERM'); + } + + return $errors; + } + + /** + * Методы административной части + *****************************************************************************************************************************************************/ + + /** + * Метод вывода списка опросов + * + * @param string $adm_dir путь к папке с шаблонами модуля + * @param string $lang_file путь к языковому файлу модуля + */ + function pollList($adm_dir, $lang_file) + { + global $AVE_DB, $AVE_Template; + + $AVE_Template->config_load($lang_file, 'showpolls'); + + $num = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_module_poll")->GetCell(); + + $limit = $this->_adminlimit; + $pages = ceil($num / $limit); + $start = get_current_page() * $limit - $limit; + + $items = array(); + $sql = $AVE_DB->Query(" + SELECT * + FROM " . PREFIX . "_module_poll + LIMIT " . $start . "," . $limit + ); + while ($row = $sql->FetchRow()) + { + $row_hits = $AVE_DB->Query(" + SELECT SUM(poll_item_hits) + FROM " . PREFIX . "_module_poll_items + WHERE poll_id = '" . $row->id . "' + GROUP BY poll_id + ")->GetCell(); + + $row->sum_hits = floor($row_hits); + + $row->comments = $AVE_DB->Query(" + SELECT COUNT(*) + FROM " . PREFIX . "_module_poll_comments + WHERE poll_id = '" . $row->id . "' + ")->GetCell(); + + array_push($items, $row); + } + + if ($num > $limit) + { + $page_nav = " {t} "; + $page_nav = get_pagination($pages, 'page', $page_nav); + $AVE_Template->assign('page_nav', $page_nav); + } + + $AVE_Template->assign('items', $items); + $AVE_Template->assign('content', $AVE_Template->fetch($adm_dir . 'admin_forms.tpl')); + } + + /** + * Метод создания нового опроса + * + * @param string $adm_dir путь к папке с шаблонами модуля + * @param string $lang_file путь к языковому файлу модуля + */ + function pollNew($adm_dir, $lang_file) + { + global $AVE_DB, $AVE_Template; + + $AVE_Template->config_load($lang_file, 'newpolls'); + + switch ($_REQUEST['sub']) + { + case '': + $groups = array(); + $sql = $AVE_DB->Query(" + SELECT + user_group AS id, + user_group_name AS name + FROM " . PREFIX . "_user_groups + "); + while ($row = $sql->FetchRow()) + { + $groups[$row->id] = $row->name; + } + + $AVE_Template->assign('published', time()); + $AVE_Template->assign('expire', mktime(date("H"), date("i"), 0, date("m"), date("d"), date("Y") + 10)); + + $AVE_Template->assign('groups', $groups); + $AVE_Template->assign('selected', array_keys($groups)); + $AVE_Template->assign('start', time()); + $AVE_Template->assign('end', time()); + $AVE_Template->assign('adm_dir', $adm_dir); + $AVE_Template->assign('formaction', 'index.php?do=modules&action=modedit&mod=poll&moduleaction=new&sub=save&cp=' . SESSION); + $AVE_Template->assign('content', $AVE_Template->fetch($adm_dir . 'admin_fields.tpl')); + break; + + case 'save': + + $_REQUEST['poll_published'] = $this->_mktime($_REQUEST['poll_published']); + $_REQUEST['poll_expire'] = $this->_mktime($_REQUEST['poll_expire']); + $_REQUEST['poll_status'] = (!empty($_REQUEST['poll_status'])) ? (int)$_REQUEST['poll_status'] : '0'; + $_REQUEST['poll_can_comment'] = (!empty($_REQUEST['poll_can_comment'])) ? (int)$_REQUEST['poll_can_comment'] : '0'; + + $AVE_DB->Query(" + INSERT + INTO " . PREFIX . "_module_poll + SET + id = '', + poll_title = '" . $_REQUEST['poll_name'] . "', + poll_status = '" . $_REQUEST['poll_status'] . "', + poll_groups_id = '" . @implode(',', $_REQUEST['groups']) . "', + poll_users_id = '0', + poll_users_ip = '0', + poll_can_comment = '" . $_REQUEST['poll_can_comment'] . "', + poll_start = '" . $_REQUEST['poll_published'] . "', + poll_end = '" . $_REQUEST['poll_expire'] . "' + "); + + $iid = $AVE_DB->InsertId(); + + reportLog($_SESSION['user_name'] . ' - Добавил новый опрос (' . stripslashes($_REQUEST['poll_name']) . ')'); + + header('Location:index.php?do=modules&action=modedit&mod=poll&moduleaction=edit&id=' . $iid . '&cp=' . SESSION); + exit; + } + } + + /** + * Метод записи вариантов ответа нового опроса + * + * @param int $pid идентификатор опроса + */ + function pollNewItemSave($pid) + { + global $AVE_DB; + + if (!empty($_POST['item_title'])) + { + + $position = (int)$AVE_DB->Query(" + SELECT MAX(poll_item_position) + FROM " . PREFIX . "_module_poll_items + WHERE poll_id = '" . $pid . "' + ")->GetCell() + 1; + + $AVE_DB->Query(" + INSERT + INTO " . PREFIX . "_module_poll_items + SET + id = '', + poll_id = '" . $pid . "', + poll_item_title = '" . $_REQUEST['item_title'] . "', + poll_item_hits = '" . $_REQUEST['poll_item_hits'] . "', + poll_item_color = '" . $_REQUEST['line_color'] . "', + poll_item_position = '" . $position . "' + "); + } + + reportLog($_SESSION['user_name'] . ' - Добавил новый вариант ответа (' . ($_REQUEST['item_title']) . ') для опроса', 2, 2); + + header('Location:index.php?do=modules&action=modedit&mod=poll&moduleaction=edit&id=' . $pid . '&cp=' . SESSION); + exit; + } + + /** + * Метод редактирования опроса + * + * @param string $adm_dir путь к папке с шаблонами модуля + * @param string $lang_file путь к языковому файлу модуля + * @param int $pid идентификатор опроса + */ + function pollEdit($adm_dir, $lang_file, $pid) + { + global $AVE_DB, $AVE_Template; + + $AVE_Template->config_load($lang_file, 'editpolls'); + + switch ($_REQUEST['sub']) + { + case '': + $items = array(); + $sql = $AVE_DB->Query(" + SELECT * + FROM " . PREFIX . "_module_poll_items + WHERE poll_id = '" . $pid . "' + ORDER BY poll_item_position ASC + "); + while ($row = $sql->FetchRow()) + { + array_push($items, $row); + } + + $groups = array(); + $sql = $AVE_DB->Query(" + SELECT + user_group AS id, + user_group_name AS name + FROM " . PREFIX . "_user_groups + "); + while ($row = $sql->FetchRow()) + { + $groups[$row->id] = $row->name; + } + + $row = $AVE_DB->Query(" + SELECT * + FROM " . PREFIX . "_module_poll + WHERE id = '" . $pid . "' + ")->FetchRow(); + + $AVE_Template->assign('groups', $groups); + $AVE_Template->assign('selected', explode(',', $row->poll_groups_id)); + $AVE_Template->assign('row', $row); + $AVE_Template->assign('items', $items); + $AVE_Template->assign('adm_dir', $adm_dir); + $AVE_Template->assign('start', $row->poll_start); + $AVE_Template->assign('end', $row->poll_end); + $AVE_Template->assign('formaction', 'index.php?do=modules&action=modedit&mod=poll&moduleaction=save&cp=' . SESSION . '&id=' . $pid); + $AVE_Template->assign('content', $AVE_Template->fetch($adm_dir . 'admin_fields.tpl')); + break; + + case 'sortable': + foreach ($_REQUEST['sort'] as $position => $items_id) + { + $AVE_DB->Query(" + UPDATE " . PREFIX . "_module_poll_items + SET + poll_item_position = '" . (int)$position . "' + WHERE + id = '" . (int)$items_id . "' + "); + } + exit; + } + + } + + /** + * Метод записи изменений в опросе + * + * @param int $pid идентификатор опроса + */ + function pollSave($pid) + { + global $AVE_DB; + + $AVE_DB->Query(" + UPDATE " . PREFIX . "_module_poll + SET + poll_title = '" . $_REQUEST['poll_name'] . "', + poll_status = '" . $_REQUEST['poll_status'] . "', + poll_can_comment = '" . $_REQUEST['poll_can_comment'] . "', + poll_start = '" . $this->_mktime($_REQUEST['poll_published']) . "', + poll_end = '" . $this->_mktime($_REQUEST['poll_expire']). "', + poll_groups_id = '" . @implode(',', (array)$_REQUEST['groups']) . "' + WHERE + id = '" . $pid . "' + "); + + if (!empty($_POST['del'])) + { + foreach ($_POST['del'] as $id => $field) + { + $AVE_DB->Query(" + DELETE + FROM " . PREFIX . "_module_poll_items + WHERE id = '" . $id . "' + "); + } + } + + foreach ($_POST['item_title'] as $id => $field) + { + if (!empty($field)) + { + $AVE_DB->Query(" + UPDATE " . PREFIX . "_module_poll_items + SET + poll_item_title = '" . $field . "', + poll_item_hits = '" . $_POST['poll_item_hits'][$id] . "', + poll_item_color = '" . $_POST['line_color'][$id] . "' + WHERE + id = '" . $id . "' + "); + } + } + + header('Location:index.php?do=modules&action=modedit&mod=poll&moduleaction=edit&id=' . $pid . '&cp=' . SESSION); + exit; + } + + /** + * Метод удаления опроса + * + * @param int $pid идентификатор опроса + */ + function pollDelete($pid) + { + global $AVE_DB; + + $AVE_DB->Query(" + DELETE + FROM " . PREFIX . "_module_poll + WHERE id = '" . $pid . "' + "); + $AVE_DB->Query(" + DELETE + FROM " . PREFIX . "_module_poll_items + WHERE poll_id = '" . $pid . "' + "); + $AVE_DB->Query(" + DELETE + FROM " . PREFIX . "_module_poll_comments + WHERE poll_id = '" . $pid . "' + "); + + reportLog($_SESSION['user_name'] . ' - удалил опрос (' . $pid . ')', 2, 2); + + header('Location:index.php?do=modules&action=modedit&mod=poll&moduleaction=1&cp=' . SESSION); + exit; + } + + /** + * Метод управления комментариями к опросам + * + * @param string $tpl_dir путь к папке с шаблонами модуля + * @param string $lang_file путь к языковому файлу модуля + * @param int $pid идентификатор опроса + */ + function pollCommentEdit($adm_dir, $lang_file, $pid) + { + global $AVE_DB, $AVE_Template; + + $AVE_Template->config_load($lang_file, 'showcomments'); + + switch ($_REQUEST['sub']) + { + case '': + $items = array(); + $sql = $AVE_DB->Query(" + SELECT * + FROM " . PREFIX . "_module_poll_comments + WHERE poll_id = '" . $pid . "' + "); + while ($row = $sql->FetchRow()) + { + $row->poll_comment_author = get_username_by_id($row->poll_comment_author_id); + + array_push($items, $row); + } + + $AVE_Template->assign('items', $items); + $AVE_Template->assign('adm_dir', $adm_dir); + $AVE_Template->assign('content', $AVE_Template->fetch($adm_dir . 'admin_comments.tpl')); + break; + + case 'save': + if (!empty($_POST['del'])) + { + foreach ($_POST['del'] as $id => $val) + { + $AVE_DB->Query(" + DELETE + FROM " . PREFIX . "_module_poll_comments + WHERE id = '" . $id . "' + "); + } + } + + foreach ($_POST['comment_text'] as $id => $comment) + { + if (!empty($comment)) + { + $AVE_DB->Query(" + UPDATE " . PREFIX . "_module_poll_comments + SET + poll_comment_title = '" . $_POST['comment_title'][$id] . "', + poll_comment_text = '" . $comment . "' + WHERE + id = '" . $id . "' + "); + } + } + + header('Location:index.php?do=modules&action=modedit&mod=poll&moduleaction=comments&id=' . $pid . '&cp=' . SESSION); + exit; + } + } + + /** + * Формитрование метки времени по данным полученным из выпадающих списков + * сформированных Smarty {html_select_date} и {html_select_time} + * + * @param string $date имя массива с значениями даты + * @param string $time имя массива с значениями времени + * @return unknown timestamp + */ + function _mktime($data=0) + { + $data = explode(" ", $data); + $stamp[day] = explode(".", $data[0]); + $stamp[time] = explode(":", $data[1]); + + if (!empty($stamp)) + { + $timestamp = mktime( + $stamp[time][0], + $stamp[time][1], + 0, + $stamp[day][1], + $stamp[day][0], + $stamp[day][2] + ); + } + + return $timestamp; + } +} + +?> \ No newline at end of file diff --git a/funcs/func.rewrite.php b/funcs/func.rewrite.php new file mode 100644 index 0000000..003eaa8 --- /dev/null +++ b/funcs/func.rewrite.php @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..11b1a2d --- /dev/null +++ b/index.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/lang/index.php b/lang/index.php new file mode 100644 index 0000000..4ca25aa --- /dev/null +++ b/lang/index.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/lang/ru.txt b/lang/ru.txt new file mode 100644 index 0000000..ef5588d --- /dev/null +++ b/lang/ru.txt @@ -0,0 +1,140 @@ +[showpoll] +POLL_ALREADY_POLL = "Ваше мнение уже учтено" +POLL_BUTTON_VOTE = "Голосовать" +POLL_EXPIRED = "Ваше мнние не может быть учтено, т.к. период опроса истек" +POLL_NO_PERMISSION = "Ваше мнние не может быть учтено, т.к. Вы не участвуете в опросе" +POLL_PUBLIC_TITLE = "Оставьте ваше мнение" +POLL_PUB_RESULTS = "Результаты" +POLL_VIEW_ARCHIVES = "Архив" +POLL_VOTES = "Мнений:" + +[showresult] +POLL_ACTIVE_INFO = "Опрос активен. Вы можете высказать свое мнение." +POLL_ADDED = "Добавил" +POLL_ALL_COMMENTS = "Всего комментариев:" +POLL_ALL_HITS = "Всего мнений:" +POLL_BUTTON_VOTE = "Голосовать" +POLL_DATE_FORMAT1 = "%d.%m.%Y, %H:%M" +POLL_ENDED = "Окончание опроса:" +POLL_GROUPS_PERM = "Участвующие группы:" +POLL_INACTIVE_INFO = "Опрос неактивен. Период действия опроса истек. Вы не можете оставить свой голос." +POLL_INFOS = "Дополнительная информация" +POLL_PUB_ADD_COMMENT = "Добавить комментарий" +POLL_PUB_COMMENTS = "Комментарии к опросу" +POLL_PUB_STATUS = "Статус опроса:" +POLL_QUESTION_LIST = "Варианты ответов" +POLL_RESULT_INFO = "Мнений | График | Процент" +POLL_STARTED = "Начало опроса:" +POLL_PAGE_TITLE_PREFIX = "Результаты опроса / " +POLL_GUEST = "Прохожий" +POLL_BUTTON_ADD_C = "Добавить" +POLL_CHARSET_LEFT = "осталось символов" +POLL_YOUR_NAME = "Имя" +POLL_SECURE_CODE = "Защитный код" +POLL_ERROR_NO_TITLE = "Пожалуйста, укажите заголовок комментария" +POLL_ERROR_NO_TEXT = "Пожалуйста, напишите комментарий длинной не менее 10 символов" +POLL_ERROR_NO_SCODE = "Пожалуйста, укажите защитный код" + +[showarchive] +POLL_ARCHIVE_HITS = "Мнений" +POLL_ARCHIVE_TITLE = "Архив опросов" +POLL_DATE_FORMAT2 = "%d.%m.%Y" +POLL_PUB_START = "Начало" +POLL_PUB_END = "Окончание" +POLL_PUB_TITLE = "Тема опроса" + +[displayform] +POLL_ADD_COMMENT = "Оставьте свой комментарий" +POLL_BUTTON_ADD_C = "Добавить комментарий" +POLL_BUTTON_RESET = "Очистить поля" +POLL_CHARSET_LEFT = "осталось символов" +POLL_CLOSE_W = "Закрыть окно" +POLL_COMMENT_ERROR = "Извините, но у вас недостаточно прав для добавления комментария." +POLL_COMMENT_M = "Текст комментария" +POLL_COMMENT_T = "Заголовок комментария" +POLL_ENTER_CODE = "Пожалуйста, укажите защитный код" +POLL_ENTER_TEXT = "Пожалуйста, напишите комментарий длинной не менее 10 символов" +POLL_ENTER_TITLE = "Пожалуйста, укажите заголовок комментария" +POLL_SECURE_CODE = "Защитный код" + +[showpolls] +POLL_ACTIONS = "Действия" +POLL_ACTIVE = "Опрос активен" +POLL_DATE_FORMAT1 = "%d.%m.%Y, %H:%M" +POLL_DELETE = "Удалить данный опрос" +POLL_DELETE_CONFIRM = "Вы уверены, что хотите удалить данный опрос?" +POLL_EDIT_POLL = "Редактировать данный опрос" +POLL_HITS_CMMENT = "Мнений/Комментариев" +POLL_INACTIVE = "Опрос неактивен" +POLL_MODULE_NAME = "Опросы" +POLL_MODULE_TITLE = "В данном разделе представлены все существующие опросы в системе." +POLL_MODULE_ALL = "Список опросов" +POLL_NAME = "Тема опроса" +POLL_NEW_LINK = "Создать новый опрос" +POLL_START_END = "Время проведения" +POLL_SYSTEM_TAG = "Системный тег" +POLL_MODULE_NO_ITEMS = "В данный момент, нет опросов." + +[editpolls] +POLL_ADD_POLL = "Создание нового опроса" +POLL_BUTTON_ADD = "Добавить вариант ответа" +POLL_BUTTON_SAVE = "Сохранить изменения" +POLL_CAN_COMMENT = "Разрешить комментарии?" +POLL_EDIT = "Редактирование опроса" +POLL_EDIT_INFO = "В данном разделе вы можете внести изменения в текущий опрос, продлить или сократить время действия опроса." +POLL_END_TIME = "Дата и время окончания:" +POLL_GROUP_INFO = "Для выбора нескольких групп, удерживайте клавишу CTRL." +POLL_MARK_DELETE = "Отметить для удаления" +POLL_NAME = "Тема опроса" +POLL_NEW_INFO = "В данном разделе вы можете создать новый опрос указав дату начала и окончания опроса. Также вы можете выбрать статус опроса, разрешить или запретить комментарии к даннному опросу и выбрать группы пользователей, которым будет доступно голосование." +POLL_NO = "Нет" +POLL_QUESTION_COLOR = "Цвет (например #F96600)" +POLL_QUESTION_HITS = "Мнений" +POLL_QUESTION_NAME = "Вариант ответа" +POLL_QUESTION_POSI = "Позиция" +POLL_SETTINGS_TITLE = "Создание нового опроса" +POLL_START_TIME = "Дата и время начала:" +POLL_STATUS = "Активный" +POLL_USER_GROUPS = "Группы пользователей, участвующие в опросе:" +POLL_YES = "Да" +POLL_MODULE_NAME = "Опросы" +POLL_QUESTIONS = "Варианты ответа" +POLL_QUESTIONS_ADD = "Добавить вариант" +POLL_QUESTION_NO_ITEMS = "Нет вариантов ответа" +POLL_POSITION_SUCCES = "Порядок сохранён" + +[newpolls] +POLL_ADD_POLL = "Создание нового опроса" +POLL_BUTTON_ADD = "Добавить вариант" +POLL_BUTTON_SAVE = "Сохранить изменения" +POLL_CAN_COMMENT = "Разрешить комментарии?" +POLL_EDIT = "Редактирование опроса" +POLL_EDIT_INFO = "В данном разделе вы можете внести изменения в текущий опрос, продлить или сократить время действия опроса." +POLL_END_TIME = "Дата и время окончания:" +POLL_GROUP_INFO = "Для выбора нескольких групп, удерживайте клавишу CTRL." +POLL_MARK_DELETE = "Отметить для удаления" +POLL_NAME = "Название опроса" +POLL_NEW_INFO = "В данном разделе вы можете создать новый опрос указав дату начала и окончания опроса. Также вы можете выбрать статус опроса, разрешить или запретить комментарии к даннному опросу и выбрать группы пользователей, которым будет доступно голосование." +POLL_NO = "Нет" +POLL_QUESTION_COLOR = "Цвет (например #F96600)" +POLL_QUESTION_HITS = "Голосов" +POLL_QUESTION_NAME = "Название вопроса" +POLL_QUESTION_POSI = "Позиция" +POLL_SETTINGS_TITLE = "Создание нового опроса" +POLL_START_TIME = "Дата и время начала:" +POLL_STATUS = "Активный" +POLL_USER_GROUPS = "Группы пользователей, участвующие в опросе:" +POLL_YES = "Да" +POLL_MODULE_NAME = "Опросы" + +[showcomments] +POLL_BUTTON_CLOSE = "Закрыть окно" +POLL_BUTTON_SAVE = "Сохранить изменения" +POLL_COMMENTS_INFO = "В данном разделе вы можете удалить или отредактировать комментарии, оставленные пользоателями для данного опроса." +POLL_COMMENTS_TITLE = "Просмотр / Редактирование комментариев" +POLL_COMMENT_AUTHOR = "Автор:" +POLL_COMMENT_DATE = "Дата создания:" +POLL_COMMENT_INFO = "Информация" +POLL_COMMENT_TITLE = "Содержимое комментария" +POLL_MARK_DELETE = "Отметить для удаления" +POLL_MODULE_NAME = "Опросы" diff --git a/module.php b/module.php new file mode 100644 index 0000000..e1a8e14 --- /dev/null +++ b/module.php @@ -0,0 +1,118 @@ +"; +} + +function mod_poll($poll_id) +{ + require_once(BASE_DIR . '/modules/poll/class.poll.php'); + require_once(BASE_DIR . '/modules/poll/funcs/func.rewrite.php'); + + $poll = new Poll; + + $tpl_dir = BASE_DIR . '/modules/poll/templates/'; + $lang_file = BASE_DIR . '/modules/poll/lang/' . $_SESSION['user_language'] . '.txt'; + + $poll->pollShow($tpl_dir, $lang_file, stripslashes($poll_id)); +} + +if (!defined('ACP') + && isset($_REQUEST['module']) && $_REQUEST['module'] == 'poll' + && isset($_REQUEST['action'])) +{ + require_once(BASE_DIR . '/modules/poll/class.poll.php'); + require_once(BASE_DIR . '/modules/poll/funcs/func.rewrite.php'); + + $poll = new Poll; + + $tpl_dir = BASE_DIR . '/modules/poll/templates/'; + $lang_file = BASE_DIR . '/modules/poll/lang/' . $_SESSION['user_language'] . '.txt'; + + switch ($_REQUEST['action']) + { + case 'result': + $poll->pollResultShow($tpl_dir, $lang_file, (int)$_REQUEST['pid']); + break; + + case 'vote': + $poll->pollVote((int)$_REQUEST['pid']); + break; + + case 'archive': + $poll->pollArchiveShow($tpl_dir, $lang_file); + break; + + case 'form': + $poll->pollCommentShow($tpl_dir, $lang_file, (int)$_REQUEST['pid'], THEME_FOLDER); + break; + + case 'comment': + $poll->pollCommentNew($tpl_dir, $lang_file, (int)$_REQUEST['pid']); + break; + } +} + +if (defined('ACP') && !empty($_REQUEST['moduleaction'])) +{ + require_once(BASE_DIR . '/modules/poll/class.poll.php'); + require_once(BASE_DIR . '/modules/poll/funcs/func.rewrite.php'); + + $poll = new Poll; + + $adm_dir = BASE_DIR . '/modules/poll/admin/'; + $lang_file = BASE_DIR . '/modules/poll/lang/' . $_SESSION['user_language'] . '.txt'; + + switch ($_REQUEST['moduleaction']) + { + case '1': + $poll->pollList($adm_dir, $lang_file); + break; + + case 'new': + $poll->pollNew($adm_dir, $lang_file); + break; + + case 'save_new': + $poll->pollNewItemSave((int)$_REQUEST['id']); + break; + + case 'edit': + $poll->pollEdit($adm_dir, $lang_file, (int)$_REQUEST['id']); + break; + + case 'save': + $poll->pollSave((int)$_REQUEST['id']); + break; + + case 'delete': + $poll->pollDelete((int)$_REQUEST['id']); + break; + + case 'comments': + $poll->pollCommentEdit($adm_dir, $lang_file, (int)$_REQUEST['id']); + break; + + case 'sort': + $poll->pollSort((array)$_REQUEST['sort']); + exit; + } +} + +?> \ No newline at end of file diff --git a/sql.php b/sql.php new file mode 100644 index 0000000..0217c04 --- /dev/null +++ b/sql.php @@ -0,0 +1,93 @@ + \ No newline at end of file diff --git a/templates/archive.tpl b/templates/archive.tpl new file mode 100644 index 0000000..c45a8f8 --- /dev/null +++ b/templates/archive.tpl @@ -0,0 +1,24 @@ +

{#POLL_ARCHIVE_TITLE#}


+
+ + + + + + + + + + + + + {foreach from=$items item=item} + + + + + + + {/foreach} +
{#POLL_PUB_TITLE#}{#POLL_PUB_START#}{#POLL_PUB_END#}{#POLL_ARCHIVE_HITS#}
{$item->poll_title}{$item->poll_start|date_format:$DATE_FORMAT|pretty_date}{$item->poll_end|date_format:$DATE_FORMAT|pretty_date}{$item->votes}

+
\ No newline at end of file diff --git a/templates/index.php b/templates/index.php new file mode 100644 index 0000000..4ca25aa --- /dev/null +++ b/templates/index.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/templates/js/common.js b/templates/js/common.js new file mode 100644 index 0000000..5e3441e --- /dev/null +++ b/templates/js/common.js @@ -0,0 +1 @@ +(function($){$.fn.extend({limit:function(limit,element){var interval,f;var self=$(this);$(this).focus(function(){interval=window.setInterval(substring,100)});$(this).blur(function(){clearInterval(interval);substring()});substringFunction="function substring(){ var val = $(self).val();var length = val.length;if(length > limit){$(self).val($(self).val().substring(0,limit));}";if(typeof element!='undefined')substringFunction+="if($(element).html() != limit-length){$(element).html((limit-length<=0)?'0':limit-length);}";substringFunction+="}";eval(substringFunction);substring()}})})(jQuery); \ No newline at end of file diff --git a/templates/poll_form.tpl b/templates/poll_form.tpl new file mode 100644 index 0000000..046faac --- /dev/null +++ b/templates/poll_form.tpl @@ -0,0 +1,93 @@ + + + + +{#POLL_ADD_COMMENT#} + + + + + + + + + +
{#POLL_ADD_COMMENT#}
+ +
+ {if $cancomment != 1} +

{#POLL_COMMENT_ERROR#}

+

 

+

+ {else} +
+ {if $errors}
    + {foreach from=$errors item=error}
  • {$error|escape}
  • + {/foreach} +
{/if} +
+ + +

+ +
+ +{* + {#POLL_CHARSET_LEFT#} +*} + +
+ + {if $anti_spam == 1} +
+{* + +
+
+ + +*} +

+ +
+
+
+

+
+ {/if} + +

+   + +

+
+ {/if} +
+ + + diff --git a/templates/poll_nav.tpl b/templates/poll_nav.tpl new file mode 100644 index 0000000..7381461 --- /dev/null +++ b/templates/poll_nav.tpl @@ -0,0 +1,10 @@ +

{$poll->poll_title}

+
+

+ {foreach from=$items item=item} +  {$item->poll_item_title}
+ {/foreach} +

+   + +
\ No newline at end of file diff --git a/templates/poll_nav_result.tpl b/templates/poll_nav_result.tpl new file mode 100644 index 0000000..b94079e --- /dev/null +++ b/templates/poll_nav_result.tpl @@ -0,0 +1,15 @@ +

{$poll->poll_title}

+

+ {foreach from=$items item=item} +

{$item->poll_item_title}
+
+
+
+ {#POLL_VOTES#} {$item->poll_item_hits} ({$item->sum|default:'0'}%) + {/foreach} +

+{if $poll->message != ''}

{$poll->message}

{/if} +
+   + +
\ No newline at end of file diff --git a/templates/result.tpl b/templates/result.tpl new file mode 100644 index 0000000..1a3d39a --- /dev/null +++ b/templates/result.tpl @@ -0,0 +1,181 @@ +{literal} + +{/literal} + + + + +

{$poll->poll_title|escape}

+ +
+ + + + + + + + + + + + {foreach from=$poll->items item=item} + + + + + + + {/foreach} +
{#POLL_QUESTION_LIST#}{#POLL_RESULT_INFO#}
{$item->poll_item_title|escape}
{$item->poll_item_hits}
+
+
sum}%{else}1%{/if};height:12px;background-color:{$item->poll_item_color}"> + +
+
+
{$item->sum} %
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{#POLL_INFOS#}
{#POLL_ALL_HITS#}{$poll->votes}
{#POLL_PUB_STATUS#}{if $poll->poll_end > $smarty.now}{#POLL_ACTIVE_INFO#}{else}{#POLL_INACTIVE_INFO#}{/if}
{#POLL_STARTED#}{$poll->poll_start|date_format:$TIME_FORMAT|pretty_date}
{#POLL_ENDED#}{$poll->poll_end|date_format:$TIME_FORMAT|pretty_date}
{#POLL_GROUPS_PERM#}{$poll->groups|escape}
+ + {if $poll->can_vote == 1} +
+
{$poll->poll_title|escape}
+
+ {foreach from=$poll->items item=item} +
{$item->poll_item_title|escape}
+ {/foreach} +
+
+ {/if} +
+ +{if $poll->poll_can_comment == 1} +
+
{#POLL_PUB_COMMENTS#}
+ + {#POLL_PUB_ADD_COMMENT#} | {#POLL_ALL_COMMENTS#} {$poll->count_comments}
+
+ + {foreach from=$poll->comments item=comment} + + + + + + + +
+
+ {*#POLL_ADDED#*} {$comment->lastname|escape} {$comment->firstname|escape} {$comment->poll_comment_time|date_format:$TIME_FORMAT|pretty_date} +
+
+ {$comment->poll_comment_title|escape}
+ {$comment->poll_comment_text} +
+ {/foreach} + + {if $poll->can_comment == 1} +
+ {**} + {*
*} + + + +
+

+ + +

+
+ + + +
+ {if $poll->anti_spam == 1} +

+
+
+
+

+ {/if} + +
+
+ + + {/if} +{/if} \ No newline at end of file