message
This commit is contained in:
59
system/forum/ajax/addpost.php
Normal file
59
system/forum/ajax/addpost.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
include 'init.php';
|
||||
|
||||
$ajax_start = true;
|
||||
|
||||
$tpl = new dle_template;
|
||||
$tpl->dir = ROOT_DIR.'/templates/'.$_REQUEST['skin'];
|
||||
define('TEMPLATE_DIR', $tpl->dir);
|
||||
|
||||
$name = convert_unicode($_POST['name'], $config['charset']);
|
||||
$mail = convert_unicode($_POST['mail'], $config['charset']);
|
||||
|
||||
$post_text = trim(convert_unicode($_POST['post_text'], $config['charset']));
|
||||
|
||||
$topic_title = convert_unicode($_POST['topic_title'], $config['charset']);
|
||||
|
||||
$topic_id = intval($_POST['topic_id']);
|
||||
|
||||
$forum_id = intval($_POST['forum_id']);
|
||||
|
||||
$post_id = $_POST['post_id'];
|
||||
|
||||
$ajax_adds = TRUE;
|
||||
|
||||
$access_mod = array(1);
|
||||
|
||||
require_once SYSTEM_DIR.'/forum/action/addpost.php';
|
||||
|
||||
$clear_value = "form.post_text.value = '';";
|
||||
|
||||
if(!$add_post_error){
|
||||
|
||||
$result_posts = $db->query("SELECT * FROM " . PREFIX . "_forum_posts LEFT JOIN " . USERPREFIX . "_users ON " . PREFIX . "_forum_posts.post_author=" . USERPREFIX . "_users.name WHERE " . PREFIX . "_forum_posts.topic_id = '$topic_id' ORDER BY pid DESC LIMIT 1");
|
||||
|
||||
$tid = $topic_id;
|
||||
|
||||
require_once SYSTEM_DIR.'/forum/sources/showposts.php';
|
||||
|
||||
$tpl->result['content'] = "<div id=\"blind-animation\" style=\"display:none\">".$tpl->result['posts']."<div>";
|
||||
$tpl->result['content'] = str_replace('{THEME}', $config['http_home_url'].'templates/'.$_REQUEST['skin'], $tpl->result['content']);
|
||||
|
||||
$tpl->result['content'] .= <<<HTML
|
||||
<script language='JavaScript' type="text/javascript">
|
||||
var timeval = new Date().getTime();
|
||||
var form = document.getElementById('forum-post-form');
|
||||
{$clear_value}
|
||||
</script>
|
||||
HTML;
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$tpl->result['content'] = "<script language=\"JavaScript\" type=\"text/javascript\">\n alert ('".$add_post_error."');\n </script>";
|
||||
}
|
||||
|
||||
@header("Content-type: text/html; charset=".$config['charset']);
|
||||
echo $tpl->result['content'];
|
||||
?>
|
||||
208
system/forum/ajax/dle_forum.js
Normal file
208
system/forum/ajax/dle_forum.js
Normal file
@@ -0,0 +1,208 @@
|
||||
function ajax_post_edit ( p_id ){
|
||||
if ( ! c_cache[ p_id ] || c_cache[ p_id ] == '' ){
|
||||
c_cache[ p_id ] = $('#post-id-'+p_id).html();
|
||||
}
|
||||
ShowLoading('');
|
||||
$.get( forum_ajax + "editpost.php", { id: p_id, action: "edit" }, function(data){
|
||||
HideLoading('');
|
||||
RunAjaxJS('post-id-'+p_id, data);
|
||||
setTimeout(function() {
|
||||
$("html:not(:animated)"+( ! $.browser.opera ? ",body:not(:animated)" : "")).animate({scrollTop: $("#post-id-" + p_id).offset().top - 70}, 700);
|
||||
}, 100);
|
||||
});
|
||||
return false;
|
||||
};
|
||||
function ajax_cancel_post_edit( p_id ){
|
||||
if ( c_cache[ p_id ] != "" )
|
||||
{$("#post-id-"+p_id).html(c_cache[ p_id ]);}
|
||||
return false;
|
||||
};
|
||||
function ajax_save_post_edit( c_id ){
|
||||
var post_txt = '';
|
||||
comm_edit_id = c_id;
|
||||
post_txt = $('#forum_post_'+c_id).val();
|
||||
ShowLoading('');
|
||||
$.post(forum_ajax + "editpost.php", { id: c_id, post_text: post_txt, action: "save" }, function(data){
|
||||
HideLoading('');
|
||||
$("#post-id-"+c_id).html(data);
|
||||
});
|
||||
return false;
|
||||
};
|
||||
function doAddPost(){
|
||||
var form = document.getElementById('forum-post-form');
|
||||
if (form.post_text.value == '' || form.post_text.value == ''){alert ( dle_req_field );return false;}
|
||||
ShowLoading('');
|
||||
$.post(forum_ajax + "addpost.php", { topic_id: form.topic_id.value, forum_id: form.forum_id.value, post_id: form.post_id.value, topic_title: form.topic_title.value, name: form.name.value, mail: form.mail.value, post_text: form.post_text.value, skin: dle_skin }, function(data){
|
||||
HideLoading('');
|
||||
RunAjaxJS('ajax-post', data);
|
||||
if (data != 'error' && document.getElementById('blind-animation')) {
|
||||
$("html"+( ! $.browser.opera ? ",body" : "")).animate({scrollTop: $("#ajax-post").offset().top - 70}, 1100);
|
||||
setTimeout(function() { $('#blind-animation').show('blind',{},0)}, 0);
|
||||
}
|
||||
});
|
||||
};
|
||||
function postDelete(url){
|
||||
var agree=confirm( 'Âû äåéñòâèòåëüíî õîòèòå óäàëèòü ýòî ñîîáùåíèå?' );
|
||||
if (agree)
|
||||
document.location=url;
|
||||
};
|
||||
function topicDelete(url){
|
||||
var agree=confirm( 'Âû äåéñòâèòåëüíî õîòèòå óäàëèòü ýòó òåìó?' );
|
||||
if (agree)
|
||||
document.location=url;
|
||||
};
|
||||
function rowDelete(url){
|
||||
var agree=confirm( 'Âû äåéñòâèòåëüíî õîòèòå óäàëèòü ýòó çàïèñü?' );
|
||||
if (agree)
|
||||
document.location=url;
|
||||
};
|
||||
function TopicMenu( tid, forum_url, moderation ){
|
||||
var menu=new Array();
|
||||
if (moderation)
|
||||
{
|
||||
menu[0]='<a href="' + forum_url + 'act=moderation&code=calc&tid=' + tid + '">Ïåðåñ÷èòàòü âñå â òåìå</a>';
|
||||
}
|
||||
menu[1]='<a href="' + forum_url + 'act=subscription&code=add&tid=' + tid + '">Ïîäïèñêà íà òåìó</a>';
|
||||
menu[2]='<a href="' + forum_url + 'act=_topic&code=forward&tid=' + tid + '">Ñîîáùèòü äðóãó</a>';
|
||||
menu[3]='<a href="' + forum_url + 'act=_topic&code=print&tid=' + tid + '">Âåðñèÿ äëÿ ïå÷àòè</a>';
|
||||
return menu;
|
||||
};
|
||||
function ForumMenu( fid, moderation, forum_url ){
|
||||
var menu=new Array();
|
||||
if (moderation){
|
||||
menu[0]='<a href="' + forum_url + 'showforum=' + fid + '&code=hidden">Ïîêàçàòü âñå ñêðûòûå òåìû</a>';
|
||||
menu[1]='<a href="' + forum_url + 'act=getforum&code=calc&fid=' + fid + '">Ïåðåñ÷èòàòü âñå â ôîðóìå</a>';
|
||||
}
|
||||
menu[3]='<a href="' + forum_url + 'showforum=' + fid + '&code=today">Àêòèâíûå òåìû</a>';
|
||||
menu[4]='<a href="' + forum_url + 'showforum=' + fid + '&code=noreply">Òåìû áåç îòâåòîâ</a>';
|
||||
return menu;
|
||||
};
|
||||
function PostEditMenu( pid, forum_url, page, post_n ){
|
||||
var menu=new Array();
|
||||
menu[0]='<a onclick="ajax_post_edit(\'' + pid + '\'); return false;" href="#">' + menu_short + '</a>';
|
||||
menu[1]='<a href="' + forum_url + 'act=post&code=02&pid=' + pid + '&p=' + page + '&pn=' + post_n + '">' + menu_full + '</a>';
|
||||
return menu;
|
||||
};
|
||||
function FUserMenu( url, m_id, group, forum_url ){
|
||||
var menu=new Array();
|
||||
menu[0]='<a href="' + dle_root + 'user/' + url + '">' + menu_profile + '</a>';
|
||||
menu[1]='<a href="' + dle_root + 'index.php?do=pm&doaction=newpm&user=' + m_id + '">' + menu_send + '</a>';
|
||||
menu[2]='<a href="' + forum_url + 'act=getforum&code=user&mname=' + url + '">Íàéòè òåìû ïîëüçîâàòåëÿ</a>';
|
||||
if (group == '1') {
|
||||
menu[3]='<a onclick="window.open(\'' + dle_root + dle_admin + '?mod=editusers&action=edituser&id=' + m_id + '\', \'User\',\'toolbar=0,location=0,status=0, left=0, top=0, menubar=0,scrollbars=yes,resizable=0,width=540,height=500\'); return false;" href="#">' + menu_uedit + '</a>';
|
||||
}
|
||||
return menu;
|
||||
};
|
||||
function navigation(pages_count, url){
|
||||
var page = prompt("Ïåðåéòè ê ñòðàíèöå", "");
|
||||
if (page)
|
||||
{
|
||||
if (pages_count >= page)
|
||||
{
|
||||
window.location.href = url + page;
|
||||
}
|
||||
}
|
||||
};
|
||||
function PostLink(link){
|
||||
url = window.location;
|
||||
var enterCause = prompt("Êîïèðîâàíèå ïðÿìîé ññûëêè", url + "#post-" + link);
|
||||
};
|
||||
function select_id( sid ){
|
||||
var saved = new Array();
|
||||
var clean = new Array();
|
||||
var add = 1;
|
||||
tmp = document.modform.selected_id.value;
|
||||
if( tmp != "" )
|
||||
{
|
||||
saved = tmp.split(",");
|
||||
}
|
||||
for( i = 0 ; i < saved.length; i++ )
|
||||
{
|
||||
if ( saved[i] != "" )
|
||||
{
|
||||
if ( saved[i] == sid )
|
||||
{
|
||||
add = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
clean[clean.length] = saved[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( add )
|
||||
{
|
||||
clean[ clean.length ] = sid;
|
||||
}
|
||||
|
||||
newvalue = clean.join(',');
|
||||
document.modform.selected_id.value = newvalue;
|
||||
};
|
||||
function ShowHide( name, open ){
|
||||
if (document.getElementById( name ).style.display != "none")
|
||||
{
|
||||
document.getElementById( name ).style.display = "none";
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById( name ).style.display = "";
|
||||
}
|
||||
|
||||
if (open)
|
||||
{
|
||||
document.getElementById( name ).style.display = "";
|
||||
}
|
||||
};
|
||||
function PostPreviewCompleted(){
|
||||
var post_main_obj = document.getElementById( 'post-preview' );
|
||||
var post_box_top = _get_obj_toppos( post_main_obj );
|
||||
if ( post_box_top )
|
||||
{
|
||||
scroll( 0, post_box_top - 70 );
|
||||
}
|
||||
};
|
||||
function PostPreview(){
|
||||
var post_text = "";
|
||||
post_text = document.getElementById('forum-post-form').post_text.value;
|
||||
if (post_text == ''){alert('Çàïîëíèòå âñå íåîáõîäèìûå ïîëÿ');return false}
|
||||
ShowLoading('');
|
||||
$.post(forum_ajax + "post.preview.php", { post_text: post_text, skin: dle_skin}, function(data){
|
||||
HideLoading('');
|
||||
$("#post-preview").html(data);
|
||||
});
|
||||
};
|
||||
function uploadsform(open_url){
|
||||
$("#uploads-form").remove();
|
||||
ShowLoading('');
|
||||
$.post(forum_ajax + "uploads.form.php", {open_url: open_url}, function(data){
|
||||
HideLoading('');
|
||||
$("body").append( data );
|
||||
$('#uploads-form').dialog({
|
||||
autoOpen: true,
|
||||
width: 470,
|
||||
buttons: {
|
||||
"Çàêðûòü": function() {
|
||||
$(this).dialog("close");
|
||||
$("#uploads-form").remove();
|
||||
}}});
|
||||
});
|
||||
return false;
|
||||
};
|
||||
function forum_ins(name){
|
||||
var input = document.getElementById('forum-post-form').post_text;
|
||||
if (dle_txt!= "")
|
||||
{
|
||||
input.value += dle_txt;
|
||||
}
|
||||
else
|
||||
{
|
||||
input.value += "[b]"+name+"[/b],"+"\n";
|
||||
}
|
||||
};
|
||||
function CtrlEnter(event, form){
|
||||
if((event.ctrlKey) && ((event.keyCode == 0xA)||(event.keyCode == 0xD)))
|
||||
{
|
||||
form.submit.click();
|
||||
}
|
||||
};
|
||||
104
system/forum/ajax/editpost.php
Normal file
104
system/forum/ajax/editpost.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
include 'init.php';
|
||||
|
||||
if (!$is_logged){die ("error");}
|
||||
|
||||
$id = intval($_REQUEST['id']);
|
||||
|
||||
if (!$id OR !is_moderation(0, 0, $id, 'forum_post_edit'))
|
||||
{
|
||||
die ("error");
|
||||
}
|
||||
|
||||
include_once SYSTEM_DIR.'/classes/parse.class.php';
|
||||
|
||||
$parse = new ParseFilter(Array(), Array(), 1, 1);
|
||||
|
||||
// ********************************************************************************
|
||||
// EDIT POST
|
||||
// ********************************************************************************
|
||||
if ($_REQUEST['action'] == "edit")
|
||||
{
|
||||
$row = $db->super_query("SELECT * FROM " . PREFIX . "_forum_posts WHERE pid = $id");
|
||||
|
||||
if ($id != $row['pid']) die ("error");
|
||||
|
||||
$topic_id = $row['topic_id'];
|
||||
|
||||
$upload_var = array('area'=>"post", 'forum_id'=>$forum_id, 'topic_id'=>$topic_id, 'post_id'=>$id);
|
||||
|
||||
$ajax_post_id = $id;
|
||||
|
||||
$upload_var['reply'] = "reply";
|
||||
|
||||
$post_text = $parse->decodeBBCodes($row['post_text'], false);
|
||||
|
||||
$upload_var['bb_width'] = '99%';
|
||||
|
||||
include_once SYSTEM_DIR.'/forum/sources/components/bbcode.php';
|
||||
|
||||
$bb_code = str_replace ("{THEME}", $config['http_home_url']."templates/".$config['skin'], $bb_code);
|
||||
|
||||
|
||||
$buffer = <<<HTML
|
||||
<form method="post" name="forum_post_form_{$id}" id="forum_post_form_{$id}" action="">
|
||||
<div>{$bb_code}</div>
|
||||
<textarea id="forum_post_{$id}" name="forum_post_{$id}" onclick="setNewField(this.name, document.forum_post_form_{$id})" style="width:99%; height:150px;font-family:verdana; font-size:11px; border:1px solid #E0E0E0">{$post_text}</textarea><br>
|
||||
<div align="right" style="width:99%;"><input class=bbcodes title="$lang[bb_t_apply]" type=button onclick="ajax_save_post_edit('{$id}'); return false;" value="$lang[bb_b_apply]">
|
||||
<input class=bbcodes title="$lang[bb_t_cancel]" type=button onclick="ajax_cancel_post_edit('{$id}'); return false;" value="$lang[bb_b_cancel]">
|
||||
</div>
|
||||
</form>
|
||||
HTML;
|
||||
}
|
||||
|
||||
// ********************************************************************************
|
||||
// SAVE POST
|
||||
// ********************************************************************************
|
||||
elseif ($_REQUEST['action'] == "save")
|
||||
{
|
||||
$post_text = trim(convert_unicode($_POST['post_text'], $config['charset']));
|
||||
|
||||
$post_text = $parse->process($post_text);
|
||||
|
||||
$post_text = $parse->BB_Parse($post_text, FALSE);
|
||||
|
||||
if (!$post_text) die ("error");
|
||||
|
||||
$post_text = auto_wrap ($post_text);
|
||||
|
||||
if (strlen($post_text) > $forum_config['post_maxlen'])
|
||||
{
|
||||
die ("<script language=\"JavaScript\" type=\"text/javascript\">\n alert ('The length of the message exceeds the limit!');\n </script>");
|
||||
}
|
||||
|
||||
$edit_info = ", edit_user = '{$member_id[name]}', edit_time = '{$_TIME}'";
|
||||
|
||||
$post_text = $db->safesql($post_text);
|
||||
|
||||
$db->query("UPDATE " . PREFIX . "_forum_posts SET post_text = '$post_text' {$edit_info} WHERE pid = $id");
|
||||
|
||||
$post_text = preg_replace ("'\[hide\](.*?)\[/hide\]'si","\\1", $post_text);
|
||||
|
||||
check_attachment($pid, $post_text);
|
||||
|
||||
if (stristr ($post_text, "[attachment="))
|
||||
{
|
||||
$row = $db->super_query("SELECT * FROM " . PREFIX . "_forum_posts WHERE pid = $id");
|
||||
|
||||
$tid = $row['topic_id'];
|
||||
|
||||
$ajax_edit_attach = TRUE;
|
||||
|
||||
require_once SYSTEM_DIR.'/forum/sources/components/attachment.php';
|
||||
}
|
||||
|
||||
$buffer = stripslashes($post_text);
|
||||
|
||||
$buffer = stripslashes($buffer);
|
||||
}
|
||||
|
||||
else die ("error");
|
||||
|
||||
@header("Content-type: text/html; charset=".$config['charset']);
|
||||
echo $buffer;
|
||||
?>
|
||||
130
system/forum/ajax/init.php
Normal file
130
system/forum/ajax/init.php
Normal file
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
@error_reporting(7);
|
||||
@ini_set('display_errors', true);
|
||||
@ini_set('html_errors', false);
|
||||
|
||||
@session_start();
|
||||
|
||||
define('DATALIFEENGINE', true);
|
||||
define('ROOT_DIR', '../../..');
|
||||
define('SYSTEM_DIR', ROOT_DIR.'/system');
|
||||
|
||||
include SYSTEM_DIR.'/data/config.php';
|
||||
include SYSTEM_DIR.'/data/forum_config.php';
|
||||
include_once ROOT_DIR.'/language/'.$config['langs'].'/website.lng';
|
||||
require_once SYSTEM_DIR.'/classes/mysql.php';
|
||||
require_once SYSTEM_DIR.'/data/dbconfig.php';
|
||||
require_once SYSTEM_DIR.'/modules/functions.php';
|
||||
require_once SYSTEM_DIR.'/classes/templates.class.php';
|
||||
require_once SYSTEM_DIR.'/forum/sources/components/init.php';
|
||||
|
||||
$_TIME = time () + ($config['date_adjust'] * 60);
|
||||
|
||||
$_REQUEST['skin'] = totranslit($_REQUEST['skin'], false, false);
|
||||
|
||||
if (! @is_dir( ROOT_DIR . '/templates/' . $_REQUEST['skin'] ))
|
||||
{
|
||||
$_REQUEST['skin'] = $config['skin'];
|
||||
}
|
||||
|
||||
$user_group = $cache->get ("usergroup");
|
||||
|
||||
if (!$user_group)
|
||||
{
|
||||
$user_group = array ();
|
||||
|
||||
$db->query("SELECT * FROM " . USERPREFIX . "_usergroups ORDER BY id ASC");
|
||||
|
||||
while ($row = $db->get_row())
|
||||
{
|
||||
$user_group[$row['id']] = array ();
|
||||
|
||||
foreach ($row as $key => $value)
|
||||
{
|
||||
$user_group[$row['id']][$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$cache->set ("usergroup", $user_group);
|
||||
|
||||
$db->free();
|
||||
}
|
||||
|
||||
$config['charset'] = ($lang['charset'] != '') ? $lang['charset'] : $config['charset'];
|
||||
|
||||
require_once SYSTEM_DIR . '/modules/sitelogin.php';
|
||||
|
||||
if (!$is_logged)
|
||||
{
|
||||
$member_id['user_group'] = 5;
|
||||
}
|
||||
|
||||
if ($member_id['banned'])
|
||||
{
|
||||
die ("Hacking attempt!");
|
||||
}
|
||||
|
||||
if (!function_exists('convert_unicode'))
|
||||
{
|
||||
function decode_to_utf8 ($int=0)
|
||||
{
|
||||
$t = '';
|
||||
|
||||
if ( $int < 0 )
|
||||
{
|
||||
return chr(0);
|
||||
}
|
||||
else if ( $int <= 0x007f )
|
||||
{
|
||||
$t .= chr($int);
|
||||
}
|
||||
else if ( $int <= 0x07ff )
|
||||
{
|
||||
$t .= chr(0xc0 | ($int >> 6));
|
||||
$t .= chr(0x80 | ($int & 0x003f));
|
||||
}
|
||||
else if ( $int <= 0xffff )
|
||||
{
|
||||
$t .= chr(0xe0 | ($int >> 12));
|
||||
$t .= chr(0x80 | (($int >> 6) & 0x003f));
|
||||
$t .= chr(0x80 | ($int & 0x003f));
|
||||
}
|
||||
else if ( $int <= 0x10ffff )
|
||||
{
|
||||
$t .= chr(0xf0 | ($int >> 18));
|
||||
$t .= chr(0x80 | (($int >> 12) & 0x3f));
|
||||
$t .= chr(0x80 | (($int >> 6) & 0x3f));
|
||||
$t .= chr(0x80 | ($int & 0x3f));
|
||||
}
|
||||
else
|
||||
{
|
||||
return chr(0);
|
||||
}
|
||||
|
||||
return $t;
|
||||
}
|
||||
|
||||
function convert_unicode ($t, $to = 'windows-1251')
|
||||
{
|
||||
$to = strtolower($to);
|
||||
|
||||
if ($to == 'utf-8') {
|
||||
|
||||
$t = preg_replace( '#%u([0-9A-F]{1,4})#ie', "decode_to_utf8(hexdec('\\1'))", utf8_encode($t) );
|
||||
$t = urldecode ($t);
|
||||
|
||||
} else {
|
||||
|
||||
$t = preg_replace( '#%u([0-9A-F]{1,4})#ie', "'&#' . hexdec('\\1') . ';'", $t );
|
||||
$t = urldecode ($t);
|
||||
$t = @html_entity_decode($t, ENT_NOQUOTES, $to);
|
||||
|
||||
}
|
||||
|
||||
return $t;
|
||||
}
|
||||
}
|
||||
|
||||
$tpl_dir = 'forum/';
|
||||
|
||||
?>
|
||||
148
system/forum/ajax/poll.php
Normal file
148
system/forum/ajax/poll.php
Normal file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
/*
|
||||
=====================================================
|
||||
DLE Forum - by DLE Files Group
|
||||
-----------------------------------------------------
|
||||
http://dle-files.ru/
|
||||
-----------------------------------------------------
|
||||
File: poll.php
|
||||
=====================================================
|
||||
Copyright (c) 2008,2010 DLE Files Group
|
||||
=====================================================
|
||||
*/
|
||||
|
||||
include 'init.php';
|
||||
|
||||
function votes ($all, $ansid) {
|
||||
|
||||
$data = array();
|
||||
$alldata = array();
|
||||
|
||||
if ($all !="") {
|
||||
$all = explode("|", $all);
|
||||
|
||||
foreach ($all as $vote) {
|
||||
list($answerid, $answervalue) = explode(":", $vote);
|
||||
$data[$answerid] = intval($answervalue);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($ansid as $id) {
|
||||
$data[$id] ++;
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$alldata[] = intval($key).":".intval($value);
|
||||
}
|
||||
|
||||
$alldata = implode("|", $alldata);
|
||||
|
||||
return $alldata;
|
||||
}
|
||||
|
||||
function get_votes ($all) {
|
||||
|
||||
$data = array();
|
||||
|
||||
if ($all != "") {
|
||||
$all = explode("|", $all);
|
||||
|
||||
foreach ($all as $vote) {
|
||||
list($answerid, $answervalue) = explode(":", $vote);
|
||||
$data[$answerid] = intval($answervalue);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
$topic_id = intval($_REQUEST['topic_id']);
|
||||
$answers = explode(" ", trim($_REQUEST['answer']));
|
||||
|
||||
$buffer = "";
|
||||
$vote_skin = strip_tags($_REQUEST['vote_skin']);
|
||||
$_IP = $db->safesql($_SERVER['REMOTE_ADDR']);
|
||||
|
||||
if ($is_logged)
|
||||
$log_id = intval($member_id['user_id']);
|
||||
else
|
||||
$log_id = $_IP;
|
||||
|
||||
$poll = $db->super_query("SELECT * FROM " . PREFIX . "_forum_topics WHERE tid = '{$topic_id}'");
|
||||
$log = $db->super_query("SELECT COUNT(*) as count FROM " . PREFIX . "_forum_poll_log WHERE topic_id = '{$topic_id}' AND member ='{$log_id}'");
|
||||
|
||||
if ($log['count'] AND $_REQUEST['action'] != "list") $_REQUEST['action'] = "results";
|
||||
$votes = "";
|
||||
|
||||
if ($_REQUEST['action'] == "vote") {
|
||||
|
||||
$votes = votes ($poll['answer'], $answers);
|
||||
$db->query("UPDATE ".PREFIX."_forum_topics set answer='$votes', poll_count=poll_count+".count($answers)." WHERE tid = '{$topic_id}'");
|
||||
$db->query("INSERT INTO ".PREFIX."_forum_poll_log (topic_id, member) VALUES('{$topic_id}', '$log_id')");
|
||||
|
||||
$_REQUEST['action'] = "results";
|
||||
}
|
||||
|
||||
if ($_REQUEST['action'] == "results") {
|
||||
|
||||
if ($votes == "") {$votes = $poll['answer']; $allcount = $poll['poll_count'];} else { $allcount = count($answers) + $poll['poll_count']; }
|
||||
|
||||
$answer = get_votes ($votes);
|
||||
$body = explode("<br />", stripslashes($poll['poll_body']));
|
||||
$pn = 0;
|
||||
|
||||
for ($i = 0; $i < sizeof($body); $i++) {
|
||||
|
||||
$num = $answer[$i];
|
||||
|
||||
if (!$num) $num = 0;
|
||||
|
||||
++$pn; if ($pn > 5) $pn = 1;
|
||||
|
||||
if ($allcount != 0) $proc = (100 * $num) / $allcount;
|
||||
else $proc = 0;
|
||||
|
||||
$proc = round($proc, 0);
|
||||
|
||||
$buffer .= <<<HTML
|
||||
{$body[$i]} - {$num} ({$proc}%)<br />
|
||||
<img src="{$config['http_home_url']}templates/{$vote_skin}/images/poll{$pn}.gif" height="10" width="{$proc}%" style="border:1px solid black"><br />
|
||||
HTML;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
elseif ($_REQUEST['action'] == "list") {
|
||||
|
||||
$body = explode("<br />", stripslashes($poll['poll_body']));
|
||||
|
||||
if (!$poll['multiple']){
|
||||
|
||||
for ($v = 0; $v < sizeof($body); $v++) {
|
||||
if (!$v) $sel = "checked"; else $sel = "";
|
||||
|
||||
$buffer .= <<<HTML
|
||||
<div><input name="dle_poll_votes" id="dle_poll_votes" type="radio" $sel value="{$v}"><label for="dle_poll_votes">{$body[$v]}</label></div>
|
||||
HTML;
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
for ($v = 0; $v < sizeof($body); $v++) {
|
||||
|
||||
$buffer .= <<<HTML
|
||||
<div><input name="dle_poll_votes[]" id="dle_poll_votes" type="checkbox" value="{$v}"><label for="dle_poll_votes">{$body[$v]}</label></div>
|
||||
HTML;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else die("error");
|
||||
|
||||
|
||||
@header("Content-type: text/css; charset=".$config['charset']);
|
||||
echo $buffer;
|
||||
?>
|
||||
38
system/forum/ajax/post.preview.php
Normal file
38
system/forum/ajax/post.preview.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
include 'init.php';
|
||||
|
||||
require_once SYSTEM_DIR.'/classes/parse.class.php';
|
||||
|
||||
if (!@is_dir(ROOT_DIR.'/templates/'.$_REQUEST['skin']) OR $_REQUEST['skin'] == "") die ("Hacking attempt!");
|
||||
|
||||
$tpl = new dle_template;
|
||||
$tpl->dir = ROOT_DIR.'/templates/'.$_REQUEST['skin'];
|
||||
define('TEMPLATE_DIR', $tpl->dir);
|
||||
|
||||
$config['charset'] = ($lang['charset'] != '') ? $lang['charset'] : $config['charset'];
|
||||
|
||||
$_POST['post_text'] = convert_unicode($_POST['post_text'], $config['charset']);
|
||||
|
||||
$parse = new ParseFilter(Array(), Array(), 1, 1);
|
||||
|
||||
$post_text = $parse->process($_POST['post_text']);
|
||||
|
||||
$post_text = $parse->BB_Parse($post_text, FALSE);
|
||||
|
||||
if( function_exists( "get_magic_quotes_gpc" ) && get_magic_quotes_gpc() ) $post_text = stripslashes( $post_text );
|
||||
|
||||
$tpl->load_template('forum/msg.tpl');
|
||||
|
||||
$tpl->set('{title}', "Preview");
|
||||
$tpl->set('{msg}', $post_text);
|
||||
|
||||
$tpl->compile('content');
|
||||
$tpl->clear();
|
||||
|
||||
$tpl->result['content'] = str_replace('{THEME}', $config['http_home_url'].'templates/'.$_REQUEST['skin'], $tpl->result['content']);
|
||||
|
||||
@header("Content-type: text/css; charset=".$config['charset']);
|
||||
|
||||
echo $tpl->result['content'];
|
||||
|
||||
?>
|
||||
34
system/forum/ajax/uploads.form.php
Normal file
34
system/forum/ajax/uploads.form.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
include 'init.php';
|
||||
|
||||
$open_url = convert_unicode($_REQUEST['open_url'], $config['charset']);
|
||||
|
||||
echo <<<HTML
|
||||
<script language="javascript" type="text/javascript">
|
||||
$('#uploads-form').dialog({
|
||||
autoOpen: true,
|
||||
width: 470,
|
||||
buttons: {
|
||||
"Close": function() {
|
||||
$(this).dialog("close");
|
||||
$("#uploads-form").remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
HTML;
|
||||
|
||||
$content = <<<HTML
|
||||
<iframe id="_AddUpload" src="{$open_url}" frameborder="0" width="100%" height="220px"></iframe>
|
||||
HTML;
|
||||
|
||||
@header("Content-type: text/html; charset=".$config['charset']);
|
||||
@header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
|
||||
@header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" );
|
||||
@header( "Cache-Control: no-store, no-cache, must-revalidate" );
|
||||
@header( "Cache-Control: post-check=0, pre-check=0", false );
|
||||
@header( "Pragma: no-cache" );
|
||||
|
||||
echo "<div id='uploads-form' title='Çàãðóçêà ôàéëîâ íà ñåðâåð' style='display:none'>".$content."</div>";
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user